Uses 911K of libraries. Click here for Pure Java version (2989L/16K).
1 | !7 |
2 | |
3 | /* Task: Search a short string in 45 MB of source codes |
4 | |
5 | Results: |
6 | simple contains() takes <10 ms when optimized |
7 | (String.indexOf is a HotSpot-intrinsic) |
8 | containsIC is really slow (700 ms) |
9 | Boyer-Moore is 150 ms (case-insensitive) or 50 ms (case-sensitive) |
10 | */ |
11 | |
12 | cprint {
|
13 | start-thread {
|
14 | SS map = dm_snippetIDToTextMap(); |
15 | time "Load texts" {
|
16 | map = mapValues upper(cloneAsHashMap(map)); |
17 | } |
18 | BoyerMooreStringSearch_upper search = new("Boyer");
|
19 | print(nChars(totalStringLength(values(map)))); |
20 | LS result = null; |
21 | repeat 10 {
|
22 | time "Search" {
|
23 | //result = keysWithValueThat(map, text -> containsIC(text, "Boyer")); |
24 | result = keysWithValueThat(map, text -> contains(text, "BOYER")); |
25 | //result = keysWithValueThat(map, text -> search.containedIn(text)); |
26 | } |
27 | } |
28 | print(result); |
29 | } |
30 | } |
download show line numbers debug dex old transpilations
Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
| Snippet ID: | #1028144 |
| Snippet name: | String search in all snippets spike |
| Eternal ID of this version: | #1028144/6 |
| Text MD5: | 89d53dcb3cadceaa2407f4e8cb0edfe5 |
| Transpilation MD5: | 39c04e449198d8231768a189cf414269 |
| Author: | stefan |
| Category: | javax |
| Type: | JavaX source code (Dynamic Module) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2020-07-12 17:35:03 |
| Source code size: | 881 bytes / 30 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 438 / 612 |
| Version history: | 5 change(s) |
| Referenced in: | [show references] |