{"id":15343819,"url":"https://github.com/rocketraman/basicmon","last_synced_at":"2025-04-06T01:27:16.035Z","repository":{"id":57722454,"uuid":"758754","full_name":"rocketraman/basicmon","owner":"rocketraman","description":"A really simple java timing/counter library","archived":false,"fork":false,"pushed_at":"2014-10-20T17:43:16.000Z","size":260,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-12T07:33:09.151Z","etag":null,"topics":[],"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/rocketraman.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2010-07-06T00:10:54.000Z","updated_at":"2023-09-18T11:08:47.000Z","dependencies_parsed_at":"2022-08-29T23:02:05.036Z","dependency_job_id":null,"html_url":"https://github.com/rocketraman/basicmon","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/rocketraman%2Fbasicmon","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rocketraman%2Fbasicmon/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rocketraman%2Fbasicmon/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rocketraman%2Fbasicmon/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rocketraman","download_url":"https://codeload.github.com/rocketraman/basicmon/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247423445,"owners_count":20936620,"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":[],"created_at":"2024-10-01T10:51:31.607Z","updated_at":"2025-04-06T01:27:16.001Z","avatar_url":"https://github.com/rocketraman.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# BasicMon - Really Simple Monitors for Java\n\nThis software is based loosely on the [Java Simon](https://github.com/virgo47/javasimon) project, which is itself\nbased loosely on the JaMON project. Java Simon has many more features than BasicMon and is almost as fast, or in\nsome cases faster (mostly with BasicMon statistics enabled). I highly recommend using Java Simon, unless:\n\n  * your project has very basic timing requirements, or\n  * the smallest timing overhead is required, or\n  * you need to be able to select different timing implementations (i.e.use of atomic classes vs synchronized keyword)\n    depending on your specific platform and concurrency requirements.\n\nThis project grew from a test case I put together for\n[Javasimon Issue #21](https://code.google.com/p/javasimon/issues/detail?id=21) which reported that Java Simon\nconfusingly included the time it took to obtain a lock to the timer reference, in the timing of the timed block\nitself.\n\nIn any of these cases, BasicMon should suit you well.\n\n## Build\n\n  * Compiled Simon jars depend on:\n    * JDK 1.6 or higher (1.5 may work but has not been tested);\n  * Use \"mvn\" to build the Simon:\n  * Commons-math is required at compile time, optional at runtime but required for extra statistics\n\n## Usage\n\nThere are two types of basic monitors available: `Counter` and `Timers`.\n\nCounters track a single long value and its average. If extra stats are enabled, its min, max, and variance are\nalso tracked.\n\nTimers measure time and tracks number of measurements (splits), total time, and average time. If extra stats are\nenabled, the timer split minimum, maximum, and variance are also tracked.\n\nExtra stats require commons-math and add significant timing overhead.\n\n### Basic Mon Manager\n\nYou obtain BasicMon implementations from the `BasicMonManager`:\n\n```java\nBasicTimer timer = BasicMonManager.getTimer(\"a-stopwatch\");\n```\n\nHere we obtained a BasicTimer monitor. If the monitor is accessed for the first time it is created. If you accessing\nan existing monitor, the existing monitor is returned. Other BasicMonManager methods can be used to obtain timers\nor counters with specific settings, or with different implementations depending on your requirements. The primary\nimplementation choice is to use synchronization-based monitors or atomic-based monitors. See the javadocs for more\ndetails and guidance.\n\n### Timer\n\nUsing a timer is simple:\n\n```java\nBasicTimerSplit split = timer.start(); // returns split object\n// here goes the measured code\nlong time = split.stop(); // returns the split time in ns\n```\n\nAfter few runs of your measured code you can get additional information:\n\n```java\nlong totalNanos = timer.getTotal();\nlong maxSplit = timer.getMax();\nlong minSplit = timer.getMin();\n... etc ...\n```\n\nThe BasicMonManager, BasicTimer's, and BasicCounter's all have useful toString implementations.\n\n### Selecting Synchronized vs Atomic Timers/Counters\n\nThe timer and counter based on java synchronization is the default. This timer is generally a good\nchoice for most situations. The alternative `java.util.concurrent.atomic`-based timer and counter may\nbe a better choice for some concurrency scenarios, or on some platforms. The included benchmarks can\nbe used to check this.\n\nOn my platform, atomics are slightly (but not much) better in single-thread operations, or with very\nhigh contention (threads much greater than CPUs), but with multi-threaded operations with a reasonable\nnumber of threads synchronization is best.\n\nUse BasicMonManager.getAtomicTimer or BasicMonManager.getAtomicCounter to get an implementation based on\n`java.util.concurrent.atomic`.\n\n## Resources\n\nProject is hosted on Github as \"basicmon\":\n  * Project page: http://github.com/rocketraman/basicmon\n  * Issue tracker: http://github.com/rocketraman/basicmon/issues\n\nProject uses the following libraries:\n  * Commons math: http://commons.apache.org/math/ (Extra statistics, optional at runtime)\n\n## License\n\nThis software is distributed under the terms of the Apache License v2:\n  * check \"LICENSE.txt\" in the root directory of the project\n  * portions of this code are from the Java Simon project, and are included with permission\n\n(c) Copyright 2014 Raman Gupta\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frocketraman%2Fbasicmon","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frocketraman%2Fbasicmon","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frocketraman%2Fbasicmon/lists"}