You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
At this point it seems difficult to come up with a faster solution (and call it your own), but I believe I can make a contribution.
I took Sam Pullara's solution @spullara and changed one code line from
int numberOfSegments = Runtime.getRuntime().availableProcessors();
to
int numberOfSegments = 20 * Runtime.getRuntime().availableProcessors();
On my MacBook Air M2 Sam's solution takes about 5.6s. With that one line changed it's about 1s faster. 20 may not be the optimal number on another machine. The key thing is to make the segments smaller, and the number of segments a multiple of the number of cores.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
At this point it seems difficult to come up with a faster solution (and call it your own), but I believe I can make a contribution.
I took Sam Pullara's solution @spullara and changed one code line from
int numberOfSegments = Runtime.getRuntime().availableProcessors();
to
int numberOfSegments = 20 * Runtime.getRuntime().availableProcessors();
On my MacBook Air M2 Sam's solution takes about 5.6s. With that one line changed it's about 1s faster. 20 may not be the optimal number on another machine. The key thing is to make the segments smaller, and the number of segments a multiple of the number of cores.
Beta Was this translation helpful? Give feedback.
All reactions