Libraryless. Click here for Pure Java version (5776L/32K).
static final new ConcurrentHashMap<Class, _MethodCache> getMethodCache_chm; static _MethodCache getMethodCache_chm(Class c) { _MethodCache cache = getMethodCache_chm.get(c); if (cache == null) getMethodCache_chm.put(c, cache = _MethodCache(c)); ret cache; } // This one gets ~44 mill/s cache lookups which is definitely better than the old method svoid bench_concurrentHashMapBasedMethodCache() { print("Loading 1000 classes"); L<Class> classes = map classForName(takeFirst(1000, classNamesInJigsawModule("java.base"))); print("Have " + nClasses(classes) + ". Filling method caches"); time { for (c : classes) assertNotNull(getMethodCache_chm(c)); } print("Looking them up again."); benchFor5(-> { for (c : classes) assertNotNull(getMethodCache_chm(c)); }); print("Classes in method cache: " + l(getMethodCache_chm)); }
Began life as a copy of #1034268
download show line numbers debug dex old transpilations
Travelled to 3 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj
No comments. add comment
Snippet ID: | #1034269 |
Snippet name: | bench_concurrentHashMapBasedMethodCache |
Eternal ID of this version: | #1034269/7 |
Text MD5: | ffaf7b3dd237d1bcb6f3b5f7cd1b7df5 |
Transpilation MD5: | 0177fbe762c32b5fc7b82e5a77314bc5 |
Author: | stefan |
Category: | javax / performance |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-01-29 15:57:14 |
Source code size: | 881 bytes / 24 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 135 / 212 |
Version history: | 6 change(s) |
Referenced in: | #1006654 - Standard functions list 2 (LIVE, continuation of #761) #1034270 - bench_concurrentHashMapBasedMethodCache_tweaked |