<s> from __future__ import print_function <EOL> import os <EOL> import sys <EOL> import time <EOL> import numpy as np <EOL> import chararray <EOL> import recarray <EOL> import recarray2 <EOL> usage = """<STR_LIT>""" % sys . argv [ <NUM_LIT:0> ] <EOL> try : <EOL> reclen = int ( sys . argv [ <NUM_LIT:1> ] ) <EOL> except : <EOL> print ( usage ) <EOL> sys . exit ( ) <EOL> delta = <NUM_LIT> <EOL> x1 = np . array ( np . arange ( reclen ) ) <EOL> x2 = chararray . array ( None , itemsize = <NUM_LIT:7> , shape = reclen ) <EOL> x3 = np . array ( np . arange ( reclen , reclen * <NUM_LIT:3> , <NUM_LIT:2> ) , np . Float64 ) <EOL> r1 = recarray . fromarrays ( [ x1 , x2 , x3 ] , names = '<STR_LIT>' ) <EOL> r2 = recarray2 . fromarrays ( [ x1 , x2 , x3 ] , names = '<STR_LIT>' ) <EOL> print ( "<STR_LIT>" , r2 . shape ) <EOL> print ( "<STR_LIT>" ) <EOL> print ( "<STR_LIT>" ) <EOL> t1 = time . clock ( ) <EOL> for row in range ( reclen ) : <EOL> r1 . field ( "<STR_LIT:c>" ) [ row ] = float ( row ** <NUM_LIT:2> ) <EOL> t2 = time . clock ( ) <EOL> origtime = round ( t2 - t1 , <NUM_LIT:3> ) <EOL> print ( "<STR_LIT>" , origtime , "<STR_LIT>" , int ( reclen / ( origtime + delta ) ) ) <EOL> print ( ) <EOL> print ( "<STR_LIT>" ) <EOL> print ( "<STR_LIT>" ) <EOL> t1 = time . clock ( ) <EOL> for row in range ( reclen ) : <EOL> rec = r2 . _row ( row ) <EOL> rec . c = float ( row ** <NUM_LIT:2> ) <EOL> t2 = time . clock ( ) <EOL> ttime = round ( t2 - t1 , <NUM_LIT:3> ) <EOL> print ( "<STR_LIT>" , ttime , "<STR_LIT>" , int ( reclen / ( ttime + delta ) ) , <EOL> end = '<STR_LIT:U+0020>' ) <EOL> print ( "<STR_LIT>" , round ( origtime / ttime , <NUM_LIT:3> ) ) <EOL> print ( ) <EOL> print ( "<STR_LIT>" ) <EOL> print ( "<STR_LIT>" ) <EOL> t1 = time . clock ( ) <EOL> for row in range ( reclen ) : <EOL> rec = r1 [ row ] <EOL> if rec . field ( "<STR_LIT:a>" ) < <NUM_LIT:3> : <EOL> print ( "<STR_LIT>" , rec . field ( "<STR_LIT:c>" ) , "<STR_LIT>" , row , "<STR_LIT:)>" ) <EOL> t2 = time . clock ( ) <EOL> origtime = round ( t2 - t1 , <NUM_LIT:3> ) <EOL> print ( "<STR_LIT>" , origtime , "<STR_LIT>" , int ( reclen / ( origtime + delta ) ) ) <EOL> print ( ) <EOL> print ( "<STR_LIT>" ) <EOL> print ( "<STR_LIT>" ) <EOL> t1 = time . clock ( ) <EOL> for row in range ( reclen ) : <EOL> rec = r2 . _row ( row ) <EOL> if rec . a < <NUM_LIT:3> : <EOL> print ( "<STR_LIT>" , rec . c , "<STR_LIT>" , row , "<STR_LIT:)>" ) <EOL> t2 = time . clock ( ) <EOL> ttime = round ( t2 - t1 , <NUM_LIT:3> ) <EOL> print ( "<STR_LIT>" , ttime , "<STR_LIT>" , int ( reclen / ( ttime + delta ) ) , <EOL> end = '<STR_LIT:U+0020>' ) <EOL> print ( "<STR_LIT>" , round ( origtime / ttime , <NUM_LIT:3> ) ) <EOL> print ( ) <EOL> print ( "<STR_LIT>" ) <EOL> print ( "<STR_LIT>" ) <EOL> f = open ( "<STR_LIT>" , "<STR_LIT:w>" ) <EOL> t1 = time . clock ( ) <EOL> f . write ( str ( r1 ) ) <EOL> t2 = time . clock ( ) <EOL> origtime = round ( t2 - t1 , <NUM_LIT:3> ) <EOL> f . close ( ) <EOL> os . unlink ( "<STR_LIT>" ) <EOL> print ( "<STR_LIT>" , origtime , "<STR_LIT>" , int ( reclen / ( origtime + delta ) ) ) <EOL> print ( ) <EOL> print ( "<STR_LIT>" ) <EOL> print ( "<STR_LIT>" ) <EOL> f = open ( "<STR_LIT>" , "<STR_LIT:w>" ) <EOL> t1 = time . clock ( ) <EOL> f . write ( str ( r2 ) ) <EOL> t2 = time . clock ( ) <EOL> ttime = round ( t2 - t1 , <NUM_LIT:3> ) <EOL> f . close ( ) <EOL> os . unlink ( "<STR_LIT>" ) <EOL> print ( "<STR_LIT>" , ttime , "<STR_LIT>" , int ( reclen / ( ttime + delta ) ) , end = '<STR_LIT:U+0020>' ) <EOL> print ( "<STR_LIT>" , round ( origtime / ttime , <NUM_LIT:3> ) ) <EOL> print ( ) </s>
