Skip to content

Commit

Permalink
add comparison of modifying integrator functionality to benchmarks (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
ranocha authored Oct 13, 2021
1 parent 6c89f48 commit ee644dd
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 1 deletion.
28 changes: 28 additions & 0 deletions docs/src/benchmark_python_bseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
midpoint_method = rk.loadRKM("Mid22")
up_to_order = 9


with open(io_file, 'a') as io:
print("\nModified equation", file=io)

start_time = time.time()
series = bs.modified_equation(None, None,
midpoint_method.A, midpoint_method.b,
Expand All @@ -34,3 +38,27 @@
with open(io_file, 'a') as io:
print(result, file=io)
print("", end_time - start_time, "seconds", file=io)


with open(io_file, 'a') as io:
print("\nModifying integrator", file=io)

start_time = time.time()
series = bs.modifying_integrator(None, None,
midpoint_method.A, midpoint_method.b,
up_to_order, True)
result = sum(series.values())
end_time = time.time()
with open(io_file, 'a') as io:
print(result, file=io)
print("", end_time - start_time, "seconds", file=io)

start_time = time.time()
series = bs.modifying_integrator(None, None,
midpoint_method.A, midpoint_method.b,
up_to_order, True)
result = sum(series.values())
end_time = time.time()
with open(io_file, 'a') as io:
print(result, file=io)
print("", end_time - start_time, "seconds", file=io)
4 changes: 4 additions & 0 deletions docs/src/benchmark_python_pybs.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
def first_values(f, n):
return (f(tree) for tree in islice(pybs.unordered_tree.tree_generator(), 0, n))


with open(io_file, 'a') as io:
print("\nModified equation", file=io)

start_time = time.time()
midpoint_series = midpoint_method.phi()
series = pybs.series.modified_equation(midpoint_series)
Expand Down
17 changes: 16 additions & 1 deletion docs/src/benchmarks.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,8 @@ Markdown.parse(results) # hide

Next, we look at the Python package
[`pybs`](https://github.com/henriksu/pybs)
and the following benchmark script.
and the following benchmark script. Note that this package does not provide
functionality for modifying integrators.

````@example
using BSeries, Markdown # hide
Expand Down Expand Up @@ -201,6 +202,8 @@ b = @SArray [0, 1//1]
c = @SArray [0, 1//2]
up_to_order = 9
println("Modified equation")
@time begin
series = modified_equation(A, b, c, up_to_order)
println(sum(values(series)))
Expand All @@ -210,6 +213,18 @@ end
series = modified_equation(A, b, c, up_to_order)
println(sum(values(series)))
end
println("\nModifying integrator")
@time begin
series = modifying_integrator(A, b, c, up_to_order)
println(sum(values(series)))
end
@time begin
series = modifying_integrator(A, b, c, up_to_order)
println(sum(values(series)))
end
```


Expand Down

0 comments on commit ee644dd

Please sign in to comment.