Libraryless. Click here for Pure Java version (8062L/45K).
import java.util.stream.IntStream; svoid benchDescendingIntArraySortingMethods(int n default 1000000) { int[] a = arrayOfRandomInts(n, predictableRandomizer()); print("Stream negation method"); int[] sorted = benchFor5(-> IntStream.of(a).map(i -> ~i).sorted().map(i -> ~i).toArray()); print("Negation method"); int[] sorted2 = benchFor5(-> sortIntArrayInPlaceDesc_crazyNegationAlgorithm(cloneIntArray(a)); print("Reversal method"); int[] sorted3 = benchFor5(-> sortIntArrayInPlaceDesc(cloneIntArray(a)); printStruct(takeFirst(10, sorted)); printStruct(takeFirst(10, sorted2)); printStruct(takeFirst(10, sorted3)); }
download show line numbers debug dex old transpilations
Travelled to 3 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj
No comments. add comment
Snippet ID: | #1035042 |
Snippet name: | benchDescendingIntArraySortingMethods |
Eternal ID of this version: | #1035042/1 |
Text MD5: | 9d3507d1b99dc76040fa6381181886f5 |
Transpilation MD5: | 23062490872259e4470d316cbc086940 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-03-25 21:08:57 |
Source code size: | 672 bytes / 19 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 118 / 177 |
Referenced in: | #1006654 - Standard functions list 2 (LIVE, continuation of #761) |