MattiaMontanari / openGJK

Fast and reliable implementation of the Gilbert-Johnson-Keerthi (GJK) algorithm for C, C#, Go, Matlab and Python
https://www.mattiamontanari.com/opengjk/
GNU General Public License v3.0
135 stars 37 forks source link

Publish the benchmarking code #44

Closed lucic71 closed 8 months ago

lucic71 commented 1 year ago

Hi,

I'm interested in running the benchmarks you presented here: https://www.mattiamontanari.com/opengjk/docs/benchmarks/

But I didn't find the code for doing that.

Do you consider publishing the benchmarking code in this repo?

MattiaMontanari commented 8 months ago

@lucic71 sorry for the delay! I used a very random and simplistic approach for that. I intended to have better benchmarking suite, but then I ran out of time. Here's the code:


import openGJK_cython as opengjk
import numpy as np
import google_benchmark as benchmark
from google_benchmark import Counter

@benchmark.register(name="Two")
@benchmark.option.unit(benchmark.kMicrosecond)
@benchmark.option.min_time(3)
@benchmark.option.repetitions(5)
@benchmark.option.report_aggregates_only(True) 
# @benchmark.option.use_real_time() // wallclock

def sedddsst(state):
    a = np.array([[1.0, 1.0, 1.0], [1.0, 1.0, 1.0]])
    b = np.array([[-1., -1., -1.], [-1., -1., -1.]])
    num_foo = 0
    while state:
        output = opengjk.pygjk(a, b)
        num_foo += output

@benchmark.register(name="Hundres")
@benchmark.option.unit(benchmark.kMicrosecond)
@benchmark.option.min_time(3)
@benchmark.option.repetitions(5)
@benchmark.option.report_aggregates_only(True) 

def randDist_100(state):
    a = np.arange(1, 10.0, 0.5).reshape(-1,3).astype('double')
    b = -a
    num_foo = 0
    while state:
        output = opengjk.pygjk(a, b)
        num_foo += output

@benchmark.register(name="Thousand")
@benchmark.option.unit(benchmark.kMicrosecond)
@benchmark.option.min_time(3)
@benchmark.option.repetitions(5)
@benchmark.option.report_aggregates_only(True) 

def randDist_1000(state):
    a = np.arange(1, 10.0, 0.01).reshape(-1,3).astype('double')
    b = -a
    num_foo = 0
    while state:
        output = opengjk.pygjk(a, b)
        num_foo += output