{"id":21042787,"url":"https://github.com/d-iii-s/java-ubench-agent","last_synced_at":"2025-05-15T17:31:14.090Z","repository":{"id":56664632,"uuid":"20636759","full_name":"d-iii-s/java-ubench-agent","owner":"d-iii-s","description":"Multiplatform Java agent for high-precision microbenchmarking.","archived":false,"fork":false,"pushed_at":"2024-07-12T11:19:21.000Z","size":22219,"stargazers_count":9,"open_issues_count":4,"forks_count":4,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-07-12T13:11:22.208Z","etag":null,"topics":["c","java","microbenchmarks"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/d-iii-s.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-06-09T06:30:07.000Z","updated_at":"2024-07-12T11:19:25.000Z","dependencies_parsed_at":"2024-07-12T13:21:43.038Z","dependency_job_id":null,"html_url":"https://github.com/d-iii-s/java-ubench-agent","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/d-iii-s%2Fjava-ubench-agent","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/d-iii-s%2Fjava-ubench-agent/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/d-iii-s%2Fjava-ubench-agent/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/d-iii-s%2Fjava-ubench-agent/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/d-iii-s","download_url":"https://codeload.github.com/d-iii-s/java-ubench-agent/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225365962,"owners_count":17462973,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c","java","microbenchmarks"],"created_at":"2024-11-19T14:09:02.531Z","updated_at":"2024-11-19T14:09:03.146Z","avatar_url":"https://github.com/d-iii-s.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"Microbenchmarking Agent for Java\n================================\n\nA JVMTI agent to be used with microbenchmarks. Basic features:\n\n- Reports major JVM events such as GC and JIT runs.\n- Can collect performance counters through JNI.\n- Can collect accurate time through JNI.\n\nUsage\n-----\n```java\nprivate static final int LOOPS = 10;\nprivate static final String[] EVENTS = {\n\t/* The most precise clock available. */\n\t\"SYS:wallclock-time\",\n\t/* Number of JIT compilation events. */\n\t\"JVM:compilations\",\n\t/* L1 cache misses (only Linux with PAPI). */\n\t\"PAPI:PAPI_L1_DCM\"\n};\n\npublic static void myBenchmark() {\n\t/*\n\t * We would have LOOPS measurements and we want to record these EVENTS.\n\t *\n\t * But we limit ourselves to supported events (i.e. in this case it\n\t * would remove PAPI:PAPI_L1_DCM event if libpapi would not be available\n\t * on the system.\n\t */\n\tBenchmark.init(LOOPS, Measurement.filterSupportedEvents(EVENTS));\n\n\tfor (int i = 0; i \u003c LOOPS; i++) {\n\t\t/* Start the measurement. */\n\t\tBenchmark.start();\n\n\t\t/* Here goes your code that ought to be measured. */\n\n\t\t/* Stop the measurement. */\n\t\tBenchmark.stop();\n\t}\n\n\t/* Get the results (available as Iterable\u003clong[]\u003e). */\n\tBenchmarkResults results = Benchmark.getResults();\n\n\t/* Either print them in CSV (to be later processed)... */\n\tBenchmarkResultsPrinter.toCsv(results, System.out);\n\n\t/* ... or as a space-padded table. */\n\tBenchmarkResultsPrinter.table(results, System.out);\n}\n```\n\nTo run your program with our agent, add the `ubench-agent.jar` to\nyour classpath and start JVM with the C-agent:\n`-agentpath:libubench-agent.so` (GNU/Linux)\nor `-agentpath:ubench-agent.dll` (Windows).\n\nA more generic interface `Measurement` is available if you wish to\nbind the measurement to a specific thread or if you need to measure\nmore things at once (though internal limitations of Linux perf\nsubsystem may apply).\n\nCompilation\n-----------\nYou will need recent version of Ant and GCC. Then simple\n```\nant \u0026\u0026 ant test test-junit\n```\nshall compile the agent and run the built-in tests\n(you might need to set `JAVA_HOME` if you have JDK in non-standard location).\n\nYou might also wish to execute\n```\nant lib\n```\nto create a JAR with the agent class files (it also copies the C-agent to\nthe same folder for easier use).\n\nDemo\n----\nPackage `cz.cuni.mff.d3s.perf.demo` contains a small demo: the `MeasureHashing`\nclass measures performance of a file hashing with Java built-in MD5.\nRun it with\n```\nant demo\n```\nto produce results that could look like this:\n```\ndemo:\n     [java]   SYS_WALLCLOCK JVM_COMPILATIO   PAPI_TOT_INS    PAPI_L1_DCM\n     [java]         1516055              9        5539366         107004\n     [java]         1082882              0        3994763          14362\n     [java]          983808              1        3690908          13472\n     [java]          258992              0        1551475           7049\n     [java]           69000              1         468639           1405\n     [java]           67542              0         470675           1296\n     ...\n     \u003ctruncated\u003e\n     ...\n     [java]           67091              0         470675           1286\n     [java]           68760              1         469812           1295\n     [java] Hash is d41d8cd98f00b204e9800998ecf8427e.\n```\n\nSupported events\n----------------\n\nTo list supported events, run the `ListEvents` demo program or execute\n`ant list-events`.\n\n* `SYS:wallclock-time`\n  * The most precise clock available.\n    `clock_gettime(CLOCK_MONOTONIC)` on Linux,\n    `QueryPerformanceCounter()` on Windows.\n* `SYS:thread-time`\n  * CPU thread time (i.e. not counting when thread is waiting).\n* `SYS:thread-time-rusage`\n  * Same as `SYS:thread-time` but uses data from `getrusage()` call on Linux.\n    Seems to be much less precise but it may save you one extra call if you\n    also query `SYS:forced-context-switches`. Linux only.\n* `SYS:forced-context-switches`\n  * Number of forced context switches (i.e. quantum was exhausted).\n    Linux only.\n* `JVM:compilations`\n  * Number of JIT compilation events.\n* `PAPI:*`\n  * When built on Linux with libpapi available, the agent can collect any\n    event supported by PAPI (note that you can use all the events reported\n    by `papi_avail` and `papi_native_avail`).\n  * Note that to use different components (e.g. `perf` and `rapl`), different\n    event sets has to be created.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fd-iii-s%2Fjava-ubench-agent","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fd-iii-s%2Fjava-ubench-agent","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fd-iii-s%2Fjava-ubench-agent/lists"}