Commit ba36830
authored
Add LSI benchmark system for GSL vs native Ruby comparison (#74)
* Improve GSL warning with suppression option
- Add SUPPRESS_GSL_WARNING=true env var to silence the notice
- Update warning message with clear install instructions
- Modernize README with platform-specific GSL installation steps
- Rename README.markdown to README.md
Closes #41
* Add LSI benchmark system for comparing GSL vs native Ruby
- Add benchmark/lsi_benchmark.rb with performance tests
- Add rake benchmark and rake benchmark:compare tasks
- Test add_items, build_index, classify, search, find_related
- Handle native Ruby SVD numerical instability gracefully
- Update Rakefile to reference README.md (renamed from .markdown)
Note: Native Ruby SVD has numerical limits with larger document sets.
GSL is recommended for production use with large collections.
* Exclude benchmark directory from RuboCop
* Fix benchmark to handle SVD dimension mismatch
- Catch ExceptionForMatrix::ErrDimensionMismatch in addition to Math::DomainError
- Use diverse document vocabulary to reduce SVD instability
- Reduce default benchmark sizes (5, 10, 15, 20) for native Ruby stability
- Update test queries to match new document style
* Add Benchmarks section to README with sample results
* fix: address PR review comments and fix GSL compatibility
- Replace % string formatting with format() for readability
- Fix code injection vulnerability by using JSON via stdin
- Use Bundler.with_unbundled_env so subprocess can access GSL gem
- Fix GSL::Vector missing count method (use to_a.count instead)
- Update README with Ruby 3.4+ GSL installation instructions
- Add real benchmark results showing 4x-116x speedup with GSL
The benchmark comparison now works correctly, showing GSL provides
significant speedups especially for build_index (SVD computation).1 parent 86dadd7 commit ba36830
6 files changed
Lines changed: 395 additions & 9 deletions
File tree
- benchmark
- lib/classifier
- lsi
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
18 | | - | |
19 | | - | |
| 17 | + | |
20 | 18 | | |
21 | | - | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
22 | 51 | | |
23 | 52 | | |
24 | 53 | | |
| |||
89 | 118 | | |
90 | 119 | | |
91 | 120 | | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
92 | 149 | | |
93 | 150 | | |
94 | 151 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
| 27 | + | |
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
31 | 42 | | |
32 | 43 | | |
33 | 44 | | |
| |||
0 commit comments