19 print(
"Not yet ported to rewritten Atlas-Python!")
24 import atlas, codec, file
30 importlib.reload(binary1)
32 importlib.reload(binary2)
33 importlib.reload(codec)
38 def deb():
import pdb; pdb.pm()
40 def disp_file_stats(msg_count, file_name, description):
41 size = os.stat(file_name)[stat.ST_SIZE]
42 return disp_stats(msg_count,size,description)
44 def disp_stats(count,total_len,description):
45 print(
"%s:\n Total length: %6i, Length/msg: %6.1f" % \
46 (description,total_len,1.0*total_len/count))
47 return description,total_len,1.0*total_len/count
49 def calculate_stats(msgs, codec):
52 description = codec.id
58 if type(str)==StringType:
59 total_len = total_len + len(str)
60 result_str_list.append(str)
62 total_len = total_len + str
63 msg_stats.append(disp_stats(count,total_len,description))
64 result_str = string.join(result_str_list,
"")
65 open(
"test_size.log",
"w").write(result_str)
66 os.system(
"gzip -9 test_size.log")
67 msg_stats.append(disp_file_stats(len(msgs),
"test_size.log.gz",
"gzip -9 compressed file"))
68 os.system(
"gunzip test_size.log.gz")
69 os.system(
"bzip2 -9 test_size.log")
70 msg_stats.append(disp_file_stats(len(msgs),
"test_size.log.bz2",
"bzip2 -9 compressed file"))
71 os.system(
"bunzip2 test_size.log.bz2")
76 def all_encoding_stats(file_name):
77 """output with default file_name:
78 Test file: cyphesis_atlas_XML_2000-03-27_no_obj.log
80 uncompressed gzip -9 bzip2 -9
81 XML 954.97 47.93 33.95
82 XML2_test 727.00 45.92 34.03
83 Packed 384.41 36.79 30.84
84 Bach_beta 478.61 39.11 31.35
85 Binary1_beta 380.54 38.58 32.26
86 Binary2_test 236.12 35.22 30.78
89 Test file: CyphesisClient_fromServerViewpoint2_no_obj.log
91 uncompressed gzip -9 bzip2 -9
92 XML 832.77 36.76 23.82
93 XML2_test 632.11 35.03 23.94
94 Packed 284.41 28.88 23.20
95 Bach_beta 373.68 31.91 23.28
96 Binary1_beta 277.63 30.53 24.04
97 Binary2_test 156.22 28.31 23.62
100 Test file: cyphesis_atlas_Packed_2001-07-13.log
102 uncompressed gzip -9 bzip2 -9
103 XML 1250.59 27.39 14.17
104 XML2_test 910.63 23.97 13.20
105 Packed 405.12 17.34 12.67
106 Bach_beta 544.18 18.72 12.21
107 Binary1_beta 441.45 22.03 14.34
108 Binary2_test 260.30 19.02 13.23
112 print(
"Test file:",file_name)
114 xml_codec = codec.get_XML()
116 all_msg = file.read_file(file_name)
117 print(
"Msg count:",len(all_msg))
121 all_stats.append(calculate_stats(all_msg,xml_codec))
124 all_stats.append(calculate_stats(all_msg,codec.get_XML2_test()))
127 all_stats.append(calculate_stats(all_msg,codec.get_Packed()))
130 all_stats.append(calculate_stats(all_msg,codec.get_Bach_beta()))
133 all_stats.append(calculate_stats(all_msg,codec.get_Binary1_beta()))
136 all_stats.append(calculate_stats(all_msg,codec.get_Binary2_test()))
147 filter_types = (
"uncompressed",
"gzip -9",
"bzip2 -9")
148 print(
" %10s %10s %10s" % filter_types)
149 for stat
in all_stats:
150 print(
"%-13s %10.2f %10.2f %10.2f" % (
151 stat[0][0], stat[0][2], stat[1][2], stat[2][2]))
154 all_encoding_stats(
"cyphesis_atlas_XML_2000-03-27_no_obj.log")
155 all_encoding_stats(
"CyphesisClient_fromServerViewpoint2_no_obj.log")
156 all_encoding_stats(
"cyphesis_atlas_Packed_2001-07-13.log")
159 msg = xml.string2object(
"""
161 <string name="abstract_type">operation</string>
162 <list name="parents">
163 <string>error</string>
165 <int name="serialno">2</int>
166 <int name="refno">1</int>
168 <float name="seconds">19035676005.9</float>
169 <string name="time_string">0612-01-01 07:46:45.9</string>
173 <string name="message">Account id already exist</string>
176 <string name="abstract_type">operation</string>
177 <list name="parents">
178 <string>create</string>
180 <int name="serialno">1</int>
182 <float name="seconds">19035676005.9</float>
183 <string name="time_string">0612-01-01 07:46:45.9</string>
187 <string name="password">lZYVYjmU</string>
188 <string name="id">admin</string>
189 <list name="parents">
190 <string>player</string>
203 def check_time(codec, all_msgs):
205 encode = codec.encode
209 str_all_msgs.append(encode(obj))
212 decode = codec.decode
213 if codec.id[:3]==
"XML":
216 for str
in str_all_msgs: decode(str)
220 def check_all_times():
221 for c
in (codec.get_XML(),
222 codec.get_XML2_test(),
224 codec.get_Bach_beta(),
225 codec.get_Binary1_beta()):
226 check_time(c, all_msg)