Skip to content

Some speed improvements #1

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kszilagyi
Copy link

Hi,

Thanks for this repo, it's quite useful.
Fixed some unnecessary slowdown due to boxing/unboxing and duplicated adding of results.
Passes unit tests.
Several times faster on my ad hoc dataset.

@stanpalatnik
Copy link

So we going to merge this?

@umbertogriffo
Copy link
Owner

Hi @kszilagyi I'm sorry for not having written to you earlier and thanks for the contribution.

Did you try to run PerformanceSimilarityBigger.java? because I'm not seeing great performance improvements.

As you can see, here it is the performance of the current version:

Loading words into Trie...
Loading random words into Trie...
Number Of Words inserted: 983805
Elapsed / Execute Time
Elapsed Time in milliseconds: 3549.996031
Elapsed Time in seconds: 3.549996031

Count Words Starts With rap
The Number Of Words Starts With rap is 166
Elapsed / Execute Time
Elapsed Time in milliseconds: 0.02274
Elapsed Time in seconds: 2.274E-5

Get Words Starts With rap
165
Elapsed / Execute Time
Elapsed Time in milliseconds: 52.032198
Elapsed Time in seconds: 0.052032198

(Java7) Get Words Starts With rap
Elapsed / Execute Time
Elapsed Time in milliseconds: 1.57402
Elapsed Time in seconds: 0.00157402

Similarity (Maximum Distance 1) rap
Number of words similar to word rap: 48
Elapsed / Execute Time
Elapsed Time in milliseconds: 16.308394
Elapsed Time in seconds: 0.016308394

Remove rap
Number Of Words: 983804
Elapsed / Execute Time
Elapsed Time in milliseconds: 0.040237
Elapsed Time in seconds: 4.0237E-5

Process finished with exit code 0

and here your version:

Loading words into Trie...
Loading random words into Trie...
Number Of Words inserted: 983805
Elapsed / Execute Time
Elapsed Time in milliseconds: 3499.168847
Elapsed Time in seconds: 3.499168847

Count Words Starts With rap
The Number Of Words Starts With rap is 166
Elapsed / Execute Time
Elapsed Time in milliseconds: 0.022633
Elapsed Time in seconds: 2.2633E-5

Get Words Starts With rap
165
Elapsed / Execute Time
Elapsed Time in milliseconds: 51.573188
Elapsed Time in seconds: 0.051573188

(Java7) Get Words Starts With rap
Elapsed / Execute Time
Elapsed Time in milliseconds: 1.415931
Elapsed Time in seconds: 0.001415931

Similarity (Maximum Distance 1) rap
Number of words similar to word rap: 48
Elapsed / Execute Time
Elapsed Time in milliseconds: 6.233386
Elapsed Time in seconds: 0.0062333860000000005

Remove rap
Number Of Words: 983804
Elapsed / Execute Time
Elapsed Time in milliseconds: 0.039844
Elapsed Time in seconds: 3.9844E-5

Process finished with exit code 0

I've just seen an improvement in Similarity (Maximum Distance 1) rap when it moves from ~16ms to ~6ms.

Did you have a benchmark?

@kszilagyi
Copy link
Author

Hey,

Sorry, I don't remember, it was 2 years ago...

@umbertogriffo
Copy link
Owner

@kszilagyi yep! It's understandable. If you like and if you wanted to, give me a little benchmark, and I'm going to merge speedy this time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants