moving min and max to Scheme?

"Dr. Arne Babenhauserheide" <[email protected]> Thu, 25 Sep 2025 21:54:23 +0200
Newsgroups gmane.lisp.guile.devel
Message-ID <[email protected]>
Hi,

While optimizing an implementation of levenshtein distance, I found that
(min ...) took up a significant part of the profile (16%), so I tried
replacing it with a simple implementation in Scheme. That worked out
surprisingly well (shaved off about 25% of the total runtime) and when I
benchmarked it directly it turned out to be between 1.5 and 3 times
faster than the min in numbers.c.

Would it be a good idea to move min and max from C to Scheme? And what
would be needed?

Attached is my implementation directly in arithmetic.bm

drop it into benchmark-suite/benchmarks/arithmetic.bm and run
./benchmark-guile arithmetic.bm

to see the results.

Best wishes,
Arne


-- 
Unpolitisch sein
heißt politisch sein,
ohne es zu merken.
draketo.de
arithmetic.bm (application/octet-stream, 4.3 KB) - not displayed
signature.asc (application/pgp-signature, 1.1 KB)
-----BEGIN PGP SIGNATURE-----

iQJEBAEBCAAuFiEE801qEjXQSQPNItXAE++NRSQDw+sFAmjVne8QHGFybmVfYmFi
QHdlYi5kZQAKCRAT741FJAPD69EvD/kBfuX55MKSxHMD+fPfL5IoFt5k78Ow72z2
/UduDFhVUztaY+F8e2iIN2Suxcn/02s9BTWf6k/mVtO6rXhbsS36L2nu3k4T05Qq
lsAqLcj6RqWRlaCLw+Hcth1Vmu+ZUbzrIty6hlpU73kAIWmzS57QUkL1oSTnSarr
SiFDpClqAb2IGHrE7/0MoXU9dttMfFyNReXC+LCAuE4xHajj5bDm7hKiPwmGo8bx
F1gnpryPFLZhBAy/Y/onRDydSLiRoa0I6QFd13DsSvNAkor/8eoF8vidhM19Izy5
SEykYIOxTEBlgdrvOD33tCpK3ONneFrk6MrIDZxl6jLdvDT7/s63X2pNOt/Ao3xG
lTCYRheOyLnyMTPve9kfC1D7YF1x0THl2KYsvIBWJRHT54ZUGiZrV+CaCXZoHVrm
f0vZDW6VksYC28q81r/TSH4fh8gKrM0XzshkiQnSB7KNLHjwMDLUZdgfnB6zLa+a
eztoSW//Bp7Wf/QVu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