Skip to content

Improve tests - #33

Open
psadac wants to merge 8 commits into
agnivade:masterfrom
psadac:improve-tests
Open

Improve tests#33
psadac wants to merge 8 commits into
agnivade:masterfrom
psadac:improve-tests

Conversation

@psadac

@psadac psadac commented May 21, 2025

Copy link
Copy Markdown
Contributor

I had already worked on the tests, fuzzing and benchmarks some months ago, but didn't push the changes.
A lot of changes were made to add tests on long strings and to avoid duplicating test cases.

psadac added 8 commits May 21, 2025 11:39
- add groups for future use
- compare results to other implementations
- use test cases as seeds
- add random seeds
- compare results to other implementations
- compare results to Hamming distance
- benchmarks use test cases by group
- split benchmarks for others levenshtein implementations
new targets:
- benchAll compares performance of all levenshtein distance implementations
- cover runs the tests and opens a web browser displaying annotated source code
- fuzz runs all fuzzing functions
- perf compares performance using benchstat between the last commit and uncommitted code
@agnivade

Copy link
Copy Markdown
Owner

Thanks a lot Paul for this! Please allow me to find some time to review the code.

@agnivade

agnivade commented Mar 3, 2026

Copy link
Copy Markdown
Owner

Dear me, my apologies @psadac , this totally dropped from my radar!

Are you still available to merge the PR if I begin a review?

@psadac

psadac commented Mar 19, 2026

Copy link
Copy Markdown
Contributor Author

Dear me, my apologies @psadac , this totally dropped from my radar!

Are you still available to merge the PR if I begin a review?

No need to apologize, we don''t have a deadline, let's begin a review

Comment thread .github/workflows/ci.yml
strategy:
matrix:
go-version: [1.22.x, 1.23.x]
go-version: [1.23.x, 1.24.x]

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's update these while we are at it.

Comment thread Makefile
Comment on lines +25 to +28
go test -bench="BenchmarkDistanceAgnivade" -benchmem -count=${COUNT} | tee bench_agnivade.out
go test -bench="BenchmarkDistanceArbovm" -benchmem -count=${COUNT} | tee bench_arbovm.out
go test -bench="BenchmarkDistanceDgryski" -benchmem -count=${COUNT} | tee bench_dgryski.out
benchstat -col=.name bench_agnivade.out bench_arbovm.out bench_dgryski.out | tee bench_all.out

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jub0bs - do you have any feedback here?

Comment thread Makefile
@@ -1,3 +1,9 @@
# FUNCS is the list of functions to run (all by default)
FUNCS?=./...

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-fuzz takes a regex matched against fuzz function names, not a Go package pattern. The default should be something like Fuzz or . to match all fuzz functions.

Comment thread Makefile

# cover runs the tests and opens a web browser displaying annotated source code
cover: test
@if [ $$? -eq 0 ]; then \

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not have any use. Since test is a prerequisite, Makefile will already halt it before running this target. We can remove it.

Comment thread levenshtein_test.go
// ----------------------------------

// RandRunes generates a random array of runes of maxLen length.
func RandRunes(rnd *rand.Rand, maxLen int) []rune {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's unexport RandRunes, RandRunesChange, RandRune. No external package can import them anyways.

Comment thread README.md
Leven/Tibetan/dgryski-4 1.16µs ± 0%
goos: linux
goarch: amd64
pkg: github.com/agnivade/levenshtein

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is already done in the latest README @psadac . We can remove this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants