Libraryless. Click here for Pure Java version (14735L/102K).
1 | !7 |
2 | |
3 | module ThreadComparison > DynSingleFunction {
|
4 | int multiplicity = 4; |
5 | |
6 | void doIt {
|
7 | print("Benchmarking...");
|
8 | final long endTime = sysTimePlus(5000); |
9 | final new L<AtomicLong> counts; |
10 | new L<Thread> threads; |
11 | repeat multiplicity {
|
12 | final AtomicLong c = addAndReturn(counts, new AtomicLong); |
13 | threads.add(minPriorityThread(r { while (sysNow() < endTime) incAtomicLong(c) }));
|
14 | } |
15 | repeat multiplicity {
|
16 | final AtomicLong c = addAndReturn(counts, new AtomicLong); |
17 | threads.add(maxPriorityThread(r { while (sysNow() < endTime) incAtomicLong(c) }));
|
18 | } |
19 | joinThreads(threads); |
20 | for i over threads: |
21 | print("Count " + (i+1) + " [priority " + threads.get(i).getPriority() + "]: " + counts.get(i));
|
22 | } |
23 | |
24 | visualize {
|
25 | ret northAndCenter(vstackWithSpacing( |
26 | withLabel("Multiplicity:", liveValueSpinner(dm_fieldLiveValue('multiplicity), 1, 32)),
|
27 | super.visualize()), |
28 | dm_printLogComponent()); |
29 | } |
30 | } |
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1018831 |
| Snippet name: | Thread Comparison: Max Priority vs Min Priority |
| Eternal ID of this version: | #1018831/14 |
| Text MD5: | e68c376a6974b5bba3b680ad4c1452d1 |
| Transpilation MD5: | 101e2cbee3deb7165502b324a0b0b848 |
| Author: | stefan |
| Category: | javax |
| Type: | JavaX source code (Dynamic Module) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2018-10-14 01:03:03 |
| Source code size: | 998 bytes / 30 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 820 / 1047 |
| Version history: | 13 change(s) |
| Referenced in: | [show references] |