gptc/benchmark.py

51 lines
983 B
Python
Raw Normal View History

2022-07-05 16:29:32 -07:00
import timeit
import gptc
import json
import sys
compile_iterations = 100
classify_iterations = 10000
with open("models/raw.json") as f:
raw_model = json.load(f)
with open("models/benchmark_text.txt") as f:
text = f.read()
classifier = gptc.Classifier(gptc.compile(raw_model))
print("Benchmarking GPTC on Python", sys.version)
print(
"Average compilation time over",
compile_iterations,
"iterations:",
round(
1000000
* timeit.timeit(
"gptc.compile(raw_model)",
number=compile_iterations,
globals=globals(),
)
/ compile_iterations
),
"microseconds",
)
print(
"Average classification time over",
classify_iterations,
"iterations:",
round(
1000000
* timeit.timeit(
"classifier.classify(text)",
number=classify_iterations,
globals=globals(),
)
/ classify_iterations
),
"microseconds",
)