Last active
December 15, 2024 08:18
-
-
Save izabera/16a46ed79c2248349a1fb83844686df3 to your computer and use it in GitHub Desktop.
bash arrays
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
a=({1..1000000}) | |
TIMEFORMAT=%R | |
for mult in {1..100}; do | |
printf "%s " "$mult" | |
RANDOM=0 | |
time for i in {1..100000}; do | |
: "${a[RANDOM*mult/10]}" | |
done | |
done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
isabella@melon:~$ taskset -c 4 bash array | |
1 0.362 | |
2 0.687 | |
3 0.988 | |
4 1.341 | |
5 1.680 | |
6 2.016 | |
7 2.353 | |
8 2.687 | |
9 3.037 | |
10 3.362 | |
11 3.708 | |
12 4.041 | |
13 4.378 | |
14 4.714 | |
15 5.037 | |
16 5.401 | |
17 5.787 | |
18 6.105 | |
19 6.418 | |
20 6.781 | |
21 7.126 | |
22 7.481 | |
23 7.864 | |
24 8.249 | |
25 8.612 | |
26 9.053 | |
27 9.523 | |
28 9.972 | |
29 10.469 | |
30 10.970 | |
31 11.501 | |
32 12.036 | |
33 12.621 | |
34 13.264 | |
35 13.980 | |
36 14.501 | |
37 15.177 | |
38 15.821 | |
39 16.496 | |
40 17.109 | |
41 17.729 | |
42 18.414 | |
43 19.008 | |
44 19.563 | |
45 20.157 | |
46 20.788 | |
47 21.388 | |
48 22.035 | |
49 22.780 | |
50 23.462 | |
51 24.557 | |
52 24.841 | |
53 26.844 | |
54 27.158 | |
55 27.246 | |
56 28.013 | |
57 28.729 | |
58 29.514 | |
59 30.242 | |
60 31.129 | |
61 31.940 | |
62 32.698 | |
63 33.633 | |
64 34.344 | |
65 35.237 | |
66 36.051 | |
67 36.878 | |
68 37.983 | |
69 38.595 | |
70 39.478 | |
71 40.322 | |
72 41.032 | |
73 41.955 | |
74 42.826 | |
75 43.660 | |
76 44.494 | |
77 45.450 | |
78 46.249 | |
79 47.112 | |
80 47.956 | |
81 48.849 | |
82 49.646 | |
83 50.439 | |
84 51.429 | |
85 52.237 | |
86 53.150 | |
87 53.951 | |
88 54.784 | |
89 55.580 | |
90 56.459 | |
91 57.427 | |
92 58.331 | |
93 59.186 | |
94 60.290 | |
95 60.779 | |
96 61.714 | |
97 62.616 | |
98 63.436 | |
99 64.248 | |
100 65.201 | |
isabella@melon:~$ [45m 24.3s] |
Author
izabera
commented
Dec 15, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment