<s> from __future__ import print_function <EOL> import sys <EOL> from time import time <EOL> import numpy as np <EOL> import numexpr as ne <EOL> N = <NUM_LIT:100> <EOL> M = <NUM_LIT:10> <EOL> def timed_eval ( eval_func , expr_func ) : <EOL> t1 = time ( ) <EOL> for i in range ( N ) : <EOL> r = eval_func ( expr_func ( i ) ) <EOL> if i % <NUM_LIT:10> == <NUM_LIT:0> : <EOL> sys . stdout . write ( '<STR_LIT:.>' ) <EOL> print ( "<STR_LIT>" % round ( time ( ) - t1 , <NUM_LIT:3> ) ) <EOL> print ( "<STR_LIT>" % ( N , M ) ) <EOL> a = np . arange ( M ) <EOL> expr = '<STR_LIT:+>' . join ( '<STR_LIT>' % ( i , i ) for i in range ( <NUM_LIT:50> ) ) <EOL> def non_cacheable ( i ) : <EOL> return expr + '<STR_LIT>' % i <EOL> def cacheable ( i ) : <EOL> return expr + '<STR_LIT>' <EOL> print ( "<STR_LIT>" , end = "<STR_LIT:U+0020>" ) <EOL> timed_eval ( ne . evaluate , non_cacheable ) <EOL> print ( "<STR_LIT>" , end = "<STR_LIT:U+0020>" ) <EOL> timed_eval ( ne . evaluate , cacheable ) <EOL> print ( "<STR_LIT>" , end = "<STR_LIT:U+0020>" ) <EOL> timed_eval ( eval , non_cacheable ) <EOL> print ( "<STR_LIT>" , end = "<STR_LIT:U+0020>" ) <EOL> timed_eval ( eval , cacheable ) </s>
