benwbooth / Set-IntervalTree

Perform range-based lookups on sets of ranges.
3 stars 3 forks source link

Add test to measure performance of fetch in big interval tree. #9

Open vrublev opened 6 years ago

vrublev commented 6 years ago

Noticed that latest version of Set::IntervalTree is significantly slower. Up to now was using 0.11 and was more than happy with its functionality and performance :+1:
In order to illustrate the latest problems I am observing added test to measure performance of fetch in big interval tree.

When the above test is run on my PC with Intel Core i7 on latest version the result of the test for elapsed time result is about 15-18seconds

$ git co master
$ dzil test
...
t/author-pod-syntax.t .. ok
t/fetch-nearest.t ...... ok
t/fetch_big.t .......... 2/2
#   Failed test 'We should do 10,000 fetches in less than a second'
#   at t/fetch_big.t line 41.
#     '10.0522201061249'
#         <=
#     '1'
# Looks like you failed 1 test of 2.
t/fetch_big.t .......... Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/2 subtests
t/fetch_window.t ....... ok
t/Set-IntervalTree.t ... ok
Test Summary Report
-------------------
t/fetch_big.t        (Wstat: 256 Tests: 2 Failed: 1)
  Failed test:  2
  Non-zero exit status: 1
Files=5, Tests=17, 10 wallclock secs ( 0.02 usr  0.01 sys + 10.19 cusr  0.07 csys = 10.29 CPU)
Result: FAIL
Failed 1/5 test programs. 1/17 subtests failed.
make: *** [Makefile:1018: test_dynamic] Error 255
error running make test

When I checkout manually e2f149c807267b4ffeecdc818285bf1d400abb56 the result is usually about 10ms.

$ perl fetch_big.t
1..2
ok 1 - use Set::IntervalTree;
Time elapsed was 0.00767803192138672
ok 2 - We should do 10,000 fetches in less than a second

As far as I could see the problem appeared in 909461adb024412278de36305fd6fc342be9a496, but since it is a fix plus refactor and my C++ skills are very very basic, I figured you will be much faster and efficient at spotting and fixing the issue.