Skip to content

Conversation

@maartenbreddels
Copy link
Member

Benchmark results for creating a button widgets.Button()

------------------------------------------------ benchmark: 1 tests -----------------------------------------------
Name (time in ms)              Min      Max    Mean  StdDev  Median     IQR  Outliers       OPS  Rounds  Iterations
-------------------------------------------------------------------------------------------------------------------
test_performance_create     2.8579  36.1314  3.3029  2.0412  3.0983  0.2583      1;22  302.7645     266           1
-------------------------------------------------------------------------------------------------------------------

After this PR, in combination with ipython/traitlets#639

------------------------------------------------ benchmark: 1 tests -----------------------------------------------
Name (time in ms)              Min      Max    Mean  StdDev  Median     IQR  Outliers       OPS  Rounds  Iterations
-------------------------------------------------------------------------------------------------------------------
test_performance_create     2.0695  62.7899  2.9496  3.6363  2.3238  0.8066      2;27  339.0254     290           1
-------------------------------------------------------------------------------------------------------------------

Which is a 30% performance increase.

Note that .class_traits is the same as .traits but is a classmethod, so that we can cache on a class level. Note that add_trait will create a new class, so will play nice with the cache. This is tested in case this changes.

Benchmark results for creating a button `widgets.Button()`
------------------------------------------------ benchmark: 1 tests -----------------------------------------------
Name (time in ms)              Min      Max    Mean  StdDev  Median     IQR  Outliers       OPS  Rounds  Iterations
-------------------------------------------------------------------------------------------------------------------
test_performance_create     2.8579  36.1314  3.3029  2.0412  3.0983  0.2583      1;22  302.7645     266           1
-------------------------------------------------------------------------------------------------------------------

After this PR, in combination with ipython/traitlets#639

------------------------------------------------ benchmark: 1 tests -----------------------------------------------
Name (time in ms)              Min      Max    Mean  StdDev  Median     IQR  Outliers       OPS  Rounds  Iterations
-------------------------------------------------------------------------------------------------------------------
test_performance_create     2.0695  62.7899  2.9496  3.6363  2.3238  0.8066      2;27  339.0254     290           1
-------------------------------------------------------------------------------------------------------------------

Which is a 30% performance increase.
@maartenbreddels
Copy link
Member Author

Note, without the traitlets PR this result is:

------------------------------------------------ benchmark: 1 tests -----------------------------------------------
Name (time in ms)              Min      Max    Mean  StdDev  Median     IQR  Outliers       OPS  Rounds  Iterations
-------------------------------------------------------------------------------------------------------------------
test_performance_create     2.2499  38.9077  2.6620  2.0604  2.4685  0.2669      1;22  375.6595     316           1
-------------------------------------------------------------------------------------------------------------------

self.send_state(name)

@classmethod
@functools.lru_cache(None)
Copy link
Contributor

Choose a reason for hiding this comment

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

I feel like an unlimited cache size is a bit dangerous. Maybe it's not in practice though?

@vidartf vidartf added this to the Future milestone Aug 10, 2021
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.

3 participants