Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reverse-string: add a test case with a longer string #1983

Open
norbs57 opened this issue Mar 8, 2022 · 4 comments
Open

Reverse-string: add a test case with a longer string #1983

norbs57 opened this issue Mar 8, 2022 · 4 comments

Comments

@norbs57
Copy link
Contributor

norbs57 commented Mar 8, 2022

I recently mentored a student on ReverseString who had started off with a naive algorithm that had quadratic complexity. It was a bit disappointing to see that in the benchmarks, the speedup was not that great. I noticed that all the sample strings in the test suite are rather short. Maybe we could add at least one longer string so that the performance gains of a better algorithm become more impressive?

@SaschaMann
Copy link
Contributor

Do you know how long the string would have to be for it to be noticeable in benchmarks?

Usually that would be something that an analyzer or mentor would discuss with the student though, not part of the test suite.

@norbs57
Copy link
Contributor Author

norbs57 commented Mar 8, 2022

With the current test suite (in Go), the speedup is about factor 2. After adding a 100 character string to the test, the speedup is closer to a factor 4. (Usual disclaimers about micro-benchmarks apply.)

@norbs57
Copy link
Contributor Author

norbs57 commented Mar 8, 2022

To be more precise - the Go benchmark test for ReverseString currently takes the average of the execution time of all test cases defined in canonical-data.json. If the benchmark data consist of a single 100-character string only, then the speedup is about a factor 5.

@SaschaMann
Copy link
Contributor

I think a 100 character string would definitely be reasonable to have. I'd be in favour of adding it if you want to open a PR.

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

No branches or pull requests

2 participants