-
Notifications
You must be signed in to change notification settings - Fork 5
/
stringencoding.py
30 lines (21 loc) · 959 Bytes
/
stringencoding.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/python
import bytebuffer
TEST = "StringEncodingTest"
INPUT = "utf8.txt"
def runTest(conversion_type, reuse, destination):
process = bytebuffer.runJava(TEST, (conversion_type, reuse, destination, INPUT))
results = []
for line in process.stdout:
results.append(float(line.split()[0]))
# Drop the first two results due to optimization sucking at first
return results[2:]
if __name__ == "__main__":
output = []
for conversion_type in ("bytebuffer", "string", "string2", "chars", "custom"):
for reuse in ("once", "reuse"):
for destination in ("array", "buffer"):
results = runTest(conversion_type, reuse, destination)
print conversion_type, reuse, destination, min(results)
for value in results:
output.append((conversion_type, reuse, destination, value))
bytebuffer.saveCSVResults("stringencoding.csv", output)