A simple python package to test the computation speed of different expressions.
- E.g., does
x*x*x*x*x*x
orx**6
run faster?
To install this package, run the install script (or run the commands in your terminal).
See the Example section below for an in-depth example for how to use this package.
- The
test
method will perform a test given two expressions, an iteration count, and a sample count. - The
tprint
method will print the data from the test. - The
plot
method will plot the data so you can see visually how the expressions compare against each other and a control.
from comptester import tester
# Defining parameters
multiplication = "x*x*x*x*x*x" # Compute x^6 by multiplication
power = "x**6" # Compute x^6 by power
iteration_count = 100000 # Number of times each expression is tested in a sample
samples = 100 # Number of samples to collect
# Run the test and store it in the 'test' variable
test = tester.test(
expr1=multiplication,
expr2=power,
iters=iteration_count,
sample_count=samples,
)
# Print the test results to the console
# tester.tprint(test)
# Plot the test results
tester.plot(test)
The example code above produces the following plot: