Skip to content

glm.min and glm.max benchmark slower than python 3.11 min and max operating over glm.array[glm.c_float] #211

@cspotcode

Description

@cspotcode

My benchmark was pretty informal, I used this hyperfine invocation:

> hyperfine --runs 5 --parameter-list impl pyglm,python 'python .\test-{impl}-min-max.py'

The two python scripts were this file, but with one of the two benchmarks uncommented in each:

import glm
from glm import min as glm_min

a = glm.array([glm.vec2(x, x + 1) for x in range(0, 10000, 2)])
a_x, a_y = a.split_components()

for i in range(99999):
    # PyGLM
    # glm_min(a_x)
    # glm_min(a_y)

    # Python
    min(a_x)
    min(a_y)

I got this output:

Benchmark 1: python .\test-pyglm-min-max.py
  Time (mean ± σ):     16.518 s ±  0.171 s    [User: 9.596 s, System: 0.023 s]
  Range (min … max):   16.370 s … 16.798 s    5 runs

Benchmark 2: python .\test-python-min-max.py
  Time (mean ± σ):     12.781 s ±  0.093 s    [User: 7.483 s, System: 0.023 s]
  Range (min … max):   12.705 s … 12.936 s    5 runs

Summary
  'python .\test-python-min-max.py' ran
    1.29 ± 0.02 times faster than 'python .\test-pyglm-min-max.py'

My first attempt used very small arrays. But I increased the array size a lot, and python min and max are still faster. I looked at #147, thinking maybe that slowed down min and max? But I'm not sure.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions