Uses 911K of libraries. Click here for Pure Java version (2989L/16K).
!7 /* Task: Search a short string in 45 MB of source codes Results: simple contains() takes <10 ms when optimized (String.indexOf is a HotSpot-intrinsic) containsIC is really slow (700 ms) Boyer-Moore is 150 ms (case-insensitive) or 50 ms (case-sensitive) */ cprint { start-thread { SS map = dm_snippetIDToTextMap(); time "Load texts" { map = mapValues upper(cloneAsHashMap(map)); } BoyerMooreStringSearch_upper search = new("Boyer"); print(nChars(totalStringLength(values(map)))); LS result = null; repeat 10 { time "Search" { //result = keysWithValueThat(map, text -> containsIC(text, "Boyer")); result = keysWithValueThat(map, text -> contains(text, "BOYER")); //result = keysWithValueThat(map, text -> search.containedIn(text)); } } print(result); } }
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: | 435 / 606 |
| Version history: | 5 change(s) |
| Referenced in: | [show references] |