Libraryless. Click here for Pure Java version (8062L/45K).
1 | import java.util.stream.IntStream; |
2 | |
3 | svoid benchDescendingIntArraySortingMethods(int n default 1000000) {
|
4 | int[] a = arrayOfRandomInts(n, predictableRandomizer()); |
5 | |
6 | print("Stream negation method");
|
7 | int[] sorted = benchFor5(-> |
8 | IntStream.of(a).map(i -> ~i).sorted().map(i -> ~i).toArray()); |
9 | print("Negation method");
|
10 | int[] sorted2 = benchFor5(-> |
11 | sortIntArrayInPlaceDesc_crazyNegationAlgorithm(cloneIntArray(a)); |
12 | print("Reversal method");
|
13 | int[] sorted3 = benchFor5(-> |
14 | sortIntArrayInPlaceDesc(cloneIntArray(a)); |
15 | |
16 | printStruct(takeFirst(10, sorted)); |
17 | printStruct(takeFirst(10, sorted2)); |
18 | printStruct(takeFirst(10, sorted3)); |
19 | } |
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: | 331 / 423 |
| Referenced in: | [show references] |