<s> import unittest <EOL> import pandas as pd <EOL> from datetime import datetime <EOL> from pandas . util . testing import assert_frame_equal <EOL> from azure . storage import BlobService <EOL> from azureml import ( <EOL> BytesIO , <EOL> Workspace , <EOL> DataTypeIds , <EOL> serialize_dataframe , <EOL> ) <EOL> from tests import ( <EOL> load_test_settings , <EOL> ) <EOL> settings = load_test_settings ( ) <EOL> class PerformanceTests ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> self . workspace = Workspace ( <EOL> settings . workspace . id , <EOL> settings . workspace . token , <EOL> settings . workspace . endpoint <EOL> ) <EOL> self . blob = BlobService ( <EOL> settings . storage . account_name , <EOL> settings . storage . account_key <EOL> ) <EOL> def _write_blob_contents ( self , filename , data ) : <EOL> if settings . diagnostics . write_blob_contents : <EOL> with open ( '<STR_LIT>' + filename , '<STR_LIT:wb>' ) as data_file : <EOL> data_file . write ( data ) <EOL> def _write_serialized_frame ( self , filename , data ) : <EOL> if settings . diagnostics . write_serialized_frame : <EOL> with open ( '<STR_LIT>' + filename , '<STR_LIT:wb>' ) as data_file : <EOL> data_file . write ( data ) <EOL> def test_serialize_40mb_dataframe ( self ) : <EOL> blob_name = settings . storage . medium_size_blob <EOL> original_data = self . blob . get_blob_to_bytes ( settings . storage . container , blob_name ) <EOL> original_dataframe = pd . read_csv ( BytesIO ( original_data ) , header = <NUM_LIT:0> , sep = "<STR_LIT:U+002C>" , encoding = '<STR_LIT>' ) <EOL> self . _write_blob_contents ( blob_name , original_data ) <EOL> start_time = datetime . now ( ) <EOL> writer = BytesIO ( ) <EOL> serialize_dataframe ( writer , DataTypeIds . GenericCSV , original_dataframe ) <EOL> elapsed_time = datetime . now ( ) - start_time <EOL> result_data = writer . getvalue ( ) <EOL> self . _write_serialized_frame ( blob_name , result_data ) <EOL> result_dataframe = pd . read_csv ( BytesIO ( result_data ) , header = <NUM_LIT:0> , sep = "<STR_LIT:U+002C>" , encoding = '<STR_LIT>' ) <EOL> assert_frame_equal ( original_dataframe , result_dataframe ) <EOL> self . assertLess ( elapsed_time . total_seconds ( ) , <NUM_LIT:10> ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> unittest . main ( ) </s>
