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

Simplify 'hyphenize' #187

Merged
merged 1 commit into from
Apr 14, 2020
Merged

Simplify 'hyphenize' #187

merged 1 commit into from
Apr 14, 2020

Conversation

turansky
Copy link
Collaborator

@Leonya Leonya merged commit 315ea42 into JetBrains:1.4-js-ir Apr 14, 2020

map[it]!!
}
fun String.hyphenize(): String =
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@turansky do you mind writing a micro-benchmark comparing the old and the new versions? Yes, the new version is simpler, but I'm wondering if its performance is also OK. See, this function is called really often when constructing CSS, but the inputs are repeating all the time because the number of CSS properties is quite limited. Therefore memoization might be actually useful.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Readability looks more important in this case
  2. Previous code use synchronized

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Readability looks more important in this case

Why? It's a simple private utility method.

Previous code use synchronized

So?

Copy link
Collaborator Author

@turansky turansky Apr 14, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simple JS test
Simple JVM test

7.000.000 calls
My results:

// JS
Before 1885 ms 
After 1482 ms

// JVM
Before 269 ms
After 2115 ms

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simple test

The link opens an empty playground.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The link opens an empty playground.

It's a bug. Do they have issue tracker? :)
WA - Incognito mode

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, so it is significantly slower on the JVM after all, I was not completely wrong :)

Luckily, the regex version is faster in all browsers, so it's fine. Thanks for doing the tests!

It's a bug. Do they have issue tracker? :)

I think it should be reported to the regular YouTrack project, KT.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First test - border case - 50% enum constants require correction

Popular case - no correction required

// JS
Before 1632 ms
After 303 ms

@turansky turansky deleted the simplify-hyphenize branch April 15, 2020 13:26
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.

2 participants