Skip to content

Conversation

bobzhang
Copy link
Member

@bobzhang bobzhang commented Jan 13, 2017

some benchmarks:

Estimated testing time 40s (4 benchmarks x 10s). Change using -quota SECS.
┌──────────────────────────────┬──────────┬─────
│ Name                         │ Time/Run │ Percentage │
├──────────────────────────────┼──────────┼─────
│ built-in compare             │  17.24ns │     96.49% │
│ length compare               │   3.83ns │     21.44% │
│ same_length built-in compare │  17.87ns │    100.00% │
│ same_length compare          │   5.91ns │     33.06% │
└──────────────────────────────┴──────────┴─────

From here we can see that OCaml built-in string comparison behaves worst when the length is same.
Our customized comparison is fast enough (3x times faster) to justify such stub inclusion, which will boost performance a lot in performance critical code

@bobzhang
Copy link
Member Author

a more comprehensive benchmark, our local version will perform better when the length is long:

Estimated testing time 1.33333m (8 benchmarks x 10s). Change using -quota SECS.
┌───────────────────────────────────────────┬──────────┬────────────┐
│ Name                                      │ Time/Run │ Percentage │
├───────────────────────────────────────────┼──────────┼────────────┤
│ File "test.ml", line 19, characters 30-37 │  17.34ns │     98.56% │
│ File "test.ml", line 22, characters 30-37 │   6.01ns │     34.17% │
│ File "test.ml", line 25, characters 30-37 │   6.02ns │     34.23% │
│ File "test.ml", line 28, characters 30-37 │   3.56ns │     20.24% │
│ File "test.ml", line 32, characters 30-37 │  17.59ns │    100.00% │
│ File "test.ml", line 35, characters 30-37 │   6.38ns │     36.29% │
│ File "test.ml", line 38, characters 30-37 │   6.34ns │     36.02% │
│ File "test.ml", line 41, characters 30-37 │   6.05ns │     34.42% │

@bobzhang bobzhang changed the title wip fast string Jan 17, 2017
@bobzhang
Copy link
Member Author

we change to a faster string comparison function in this commit, it may change the -bs-sort order (cc @chenglou )

@bobzhang bobzhang merged commit bf9d3b8 into master Jan 17, 2017
@bobzhang bobzhang deleted the fast_string branch January 17, 2017 03:03
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.

1 participant