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

Improve EstimateReadingTime's speed by a factor 7 #2437

Merged
merged 1 commit into from
Mar 1, 2024
Merged

Improve EstimateReadingTime's speed by a factor 7 #2437

merged 1 commit into from
Mar 1, 2024

Conversation

jvoisin
Copy link
Contributor

@jvoisin jvoisin commented Feb 29, 2024

  • Make it explicit that we only care about detecting Korean/Chinese/Japanese

  • Use a more idiomatic control flow

  • Add a test for the Korean language

  • Only consider the first 250 chars. Literature says that around 100 is enough, so we're pretty large.

  • I have tested my changes

  • I read this document: https://miniflux.app/faq.html#pull-request

@jvoisin jvoisin marked this pull request as draft February 29, 2024 14:09
@jvoisin jvoisin changed the title Improve a tad EstimateReadingTime Improve EstimateReadingTime's speed by a factor 7 Feb 29, 2024
- Refactorise the tests and add some
- Use 250 signs instead of the whole text
- Only check for Korean, Chinese and Japanese script
- Add a benchmark
- Use a more idiomatic control flow

```console
$ # main branch
$ go test -bench=.
goos: linux
goarch: amd64
pkg: miniflux.app/v2/internal/reader/readingtime
BenchmarkEstimateReadingTime-12              267           4821268 ns/op
PASS
ok      miniflux.app/v2/internal/reader/readingtime     1.754s
$ # speed_up_reading_time branch
$ go test -bench=.
goos: linux
goarch: amd64
pkg: miniflux.app/v2/internal/reader/readingtime
cpu: 12th Gen Intel(R) Core(TM) i7-1265U
BenchmarkEstimateReadingTime-12             1941            653312 ns/op
PASS
ok      miniflux.app/v2/internal/reader/readingtime     1.342s
$
```
@jvoisin jvoisin marked this pull request as ready for review February 29, 2024 15:37
@fguillot fguillot merged commit ab85d4d into miniflux:main Mar 1, 2024
17 checks passed
@jvoisin jvoisin deleted the speed_up_reading_time branch March 7, 2024 13:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants