<s> try : <EOL> from pdae_cython import * <EOL> except ImportError : <EOL> from pdae_python import * <EOL> import unittest <EOL> import time <EOL> import os <EOL> try : <EOL> import cStringIO as StringIO <EOL> except ImportError : <EOL> import StringIO <EOL> CURDIR = os . path . abspath ( os . path . dirname ( __file__ ) ) <EOL> class PM_OP : <EOL> INDEX_UPDATE = <NUM_LIT:1> <EOL> TRIANGLE_ADDITION = <NUM_LIT:2> <EOL> VERTEX_ADDITION = <NUM_LIT:3> <EOL> class PDAETest ( unittest . TestCase ) : <EOL> def testLoad ( self ) : <EOL> for i in range ( <NUM_LIT:2> ) : <EOL> f = open ( os . path . join ( CURDIR , '<STR_LIT>' ) ) <EOL> if i % <NUM_LIT:2> == <NUM_LIT:0> : <EOL> f = StringIO . StringIO ( f . read ( ) ) <EOL> start = time . time ( ) <EOL> refinements = readPDAE ( f ) <EOL> after = time . time ( ) <EOL> print '<STR_LIT>' , after - start , '<STR_LIT>' <EOL> self . assertEqual ( len ( refinements ) , <NUM_LIT> ) <EOL> def testPartial ( self ) : <EOL> to_test = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> for test_file in to_test : <EOL> f = open ( os . path . join ( CURDIR , test_file ) ) <EOL> blessed_refinements = readPDAE ( f ) <EOL> B = <NUM_LIT:1> <EOL> KB = <NUM_LIT> <EOL> MB = KB * KB <EOL> test_block_sizes = [ <NUM_LIT:100> * B , <EOL> <NUM_LIT> * B , <EOL> <NUM_LIT:1> * KB , <EOL> <NUM_LIT:5> * KB , <EOL> <NUM_LIT:50> * KB , <EOL> <NUM_LIT:100> * KB , <EOL> <NUM_LIT:1> * MB , <EOL> <NUM_LIT:2> * MB , <EOL> <NUM_LIT:5> * MB ] <EOL> for block_size in test_block_sizes : <EOL> start = time . time ( ) <EOL> block_size = <NUM_LIT> <EOL> f = open ( os . path . join ( CURDIR , test_file ) ) <EOL> curdata = f . read ( block_size ) <EOL> refinements_read = <NUM_LIT:0> <EOL> num_refinements = None <EOL> all_pm_refinements = [ ] <EOL> while len ( curdata ) > <NUM_LIT:0> : <EOL> ( refinements_read , num_refinements , pm_refinements , data_left ) = readPDAEPartial ( curdata , refinements_read , num_refinements ) <EOL> all_pm_refinements . extend ( pm_refinements ) <EOL> if data_left is not None : <EOL> curdata = data_left + f . read ( block_size ) <EOL> else : <EOL> curdata = f . read ( block_size ) <EOL> after = time . time ( ) <EOL> print '<STR_LIT>' , after - start , '<STR_LIT>' <EOL> self . assertEqual ( all_pm_refinements , blessed_refinements ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> unittest . main ( ) </s>
