{"id":17004853,"url":"https://github.com/clickermonkey/statastic","last_synced_at":"2025-08-20T06:36:57.711Z","repository":{"id":152212215,"uuid":"9776913","full_name":"ClickerMonkey/Statastic","owner":"ClickerMonkey","description":"A Java library for tracking statistics over time in a round robin database. A round robin database is a fixed size database with several time spans it accumulates statistics over.","archived":false,"fork":false,"pushed_at":"2013-11-15T20:47:21.000Z","size":520,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-22T10:40:41.494Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"osl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ClickerMonkey.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}},"created_at":"2013-04-30T18:10:39.000Z","updated_at":"2019-08-13T15:20:06.000Z","dependencies_parsed_at":"2023-04-09T12:14:51.080Z","dependency_job_id":null,"html_url":"https://github.com/ClickerMonkey/Statastic","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ClickerMonkey/Statastic","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ClickerMonkey%2FStatastic","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ClickerMonkey%2FStatastic/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ClickerMonkey%2FStatastic/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ClickerMonkey%2FStatastic/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ClickerMonkey","download_url":"https://codeload.github.com/ClickerMonkey/Statastic/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ClickerMonkey%2FStatastic/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271279086,"owners_count":24731900,"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","status":"online","status_checked_at":"2025-08-20T02:00:09.606Z","response_time":69,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-14T04:44:37.455Z","updated_at":"2025-08-20T06:36:57.684Z","avatar_url":"https://github.com/ClickerMonkey.png","language":"Java","readme":"statastic\n=========\n\n![Stable](http://i4.photobucket.com/albums/y123/Freaklotr4/stage_stable.png)\n\nA Java library for tracking statistics over time in a round robin database. A round robin database is a fixed size database with several time spans it accumulates statistics over.\n\n### Terminology\n- StatPoint *- a single statistical point in an archive, contains total number of stats, their sum, min, max, and average*\n- StatArchive *- An archive contains a fixed number of points. Each point contains a summary for each statistic added to that point in the interval of time. When a point must be added when the archive is full the oldest point is overwritten.*\n- StatDatabase *- A database of round robin archives which hold the summary of a statistic over time*\n\n### Features\n- A database can be stored in memory, in a file, or in a memory-mapped file\n- Adding statistics to databases is a non-blocking operation that adds virtually no overhead.\n- All data can be written out to the backing store (memory or file) whenever there's a statistic added or at some interval.\n- An archive can be exported to a chart as a PNG, JPG, BMP, or a data file (CSV).\n- A group of databases stored in a folder can be handled/loaded all with one class (StatGroup).\n- Memory-mapped databases are fast in memory databases that the OS flushes out to a file - this is the most reliable store type.\n\n### Documentation\n- [JavaDoc](http://gh.magnos.org/?r=http://clickermonkey.github.com/Statastic/)\n\n### Examples\n\n#### Example that writes out to files in the current-working-directory of the application\n\n##### Start of Application\n\n```java\npublic class Stats\n{\n  public static StatFormat FORMAT;\n  \n  static\n  {\n  \tStatService.get();\n  \n    FORMAT = new StatFormat( ) ;      // A format that covers a year (365.25 days)\n    FORMAT.set( 0, 300205L, 12 );     // one point every 5 minutes for an hour \n    FORMAT.set( 1, 3602467L, 24 );    // one point every hour for a day\n    FORMAT.set( 2, 43229589L, 14 );   // one point every 12 hours for a week\n    FORMAT.set( 3, 86459178L, 31 );   // one point every day for a month\n    FORMAT.set( 4, 7606876923L, 52 ); // one point for every week in a year\n    FORMAT.compile();                 // database size = 3328 bytes\n  }\n  \n  // Save Statistics for MyClass\n  public static StatDatabase DB_1 = new StatDatabase(MyClass.class, FORMAT);\n\n  // Save Statistics in \"stat.db\" \n  public static StatDatabase DB_2 = new StatDatabase(new FileStore(\"stat.db\"), FORMAT);\n}\n```\n\n##### During Application Execution\n\n```java\n// Adding one when an event occurs.\nStats.DB_1.add(1f);\n\n// Adding a value over time (for example time).\nStats.DB_2.add(2.435f);\n```\n\n##### End of Application\n\n```java\n// Close the databases\nStatGroup.getRoot().close();\n\n// Stop Statistics Thread\nStatService.get().stop();\n```\n\n#### Example that saves all databases in memory-mapped files in a specific directory AND databases are dynamically created/loaded (through take).\n\n##### Start of Application\n\n```java\npublic class Stats\n{\n  public static StatFormat FORMAT;\n  public static StatGroup GROUP;\n  \n  static\n  {\n  \tStatService.get();\n  \n    FORMAT = new StatFormat( 5 );     // A format that covers a year (365.25 days)\n    FORMAT.set( 0, 300205L, 12 );     // one point every 5 minutes for an hour \n    FORMAT.set( 1, 3602467L, 24 );    // one point every hour for a day\n    FORMAT.set( 2, 43229589L, 14 );   // one point every 12 hours for a week\n    FORMAT.set( 3, 86459178L, 31 );   // one point every day for a month\n    FORMAT.set( 4, 7606876923L, 52 ); // one point for every week in a year\n    FORMAT.compile();                 // database size = 3328 bytes\n    \n    GROUP = new StatGroup( \"/home/stat/my_app_stats\" );\n    GROUP.setFactory( new MappedStoreFactory() );\n    GROUP.setEnabledDefault(true);\n    GROUP.setFormatDefault(FORMAT);\n  }\n  \n  public static void add(String name, float statistic)\n  {\n    GROUP.take( name ).add( statistic );\n  }\n  \n  public static close()\n  {\n    // Close the databases\n    GROUP.close();\n    \n    // Stop Statistics Thread\n    StatService.get().stop();\n  }\n}\n```\n\n##### During Application Execution\n\n```java\n// Adding one when an event occurs and creating the \"number_of_events\" database if it doesn't exist already.\nStats.add( \"number_of_events\", 1.0f );\n\n// Adding a value over time (for example elapsed time) and creating the \"event_elapsed_time\" database if it \n// doesn't exist already.\nStats.add( \"event_elapsed_time\", 2.435f );\n```\n\n##### End of Application\n\n```java\nStats.close();\n```\n\n#### Example that exports a StatArchive to an image and CSV file\n\n```java\n// Archive 0 = past hour\nStatExport.export(Stats.DB_1.getArchive(0), Type.CSV, new File(\"sdb.csv\"));\nStatExport.export(Stats.DB_2.getArchive(0), Type.PNG, new File(\"sdb.png\"));\n```\n\n### Builds\n- [statastics-1.0.0.jar](http://gh.magnos.org/?r=https://github.com/ClickerMonkey/Statastic/blob/master/build/statastics-1.0.0.jar?raw=true)\n- [statastics-src-1.0.0.jar](http://gh.magnos.org/?r=https://github.com/ClickerMonkey/Statastic/blob/master/build/statastics-src-1.0.0.jar?raw=true) *- includes source code*\n- [statastics-all-1.0.0.jar](http://gh.magnos.org/?r=https://github.com/ClickerMonkey/Statastic/blob/master/build/statastics-1.0.0.jar?raw=true) *- includes all dependencies*\n- [statastics-all-src-1.0.0.jar](http://gh.magnos.org/?r=https://github.com/ClickerMonkey/Statastic/blob/master/build/statastics-src-1.0.0.jar?raw=true) *- includes all dependencies and source code*\n\n### Dependencies\n- [Daperz](http://gh.magnos.org/?r=https://github.com/ClickerMonkey/Daperz)\n- [Curity](http://gh.magnos.org/?r=https://github.com/ClickerMonkey/Curity)\n- [Surfice](http://gh.magnos.org/?r=https://github.com/ClickerMonkey/Surfice)\n- [Buffero](http://gh.magnos.org/?r=https://github.com/ClickerMonkey/Buffero)\n- [Testility](http://gh.magnos.org/?r=https://github.com/ClickerMonkey/Testility) *for unit tests*\n\n### Testing Examples\n- [Testing/org/magnos/stat](http://gh.magnos.org/?r=https://github.com/ClickerMonkey/Statastic/tree/master/Testing/org/magnos/stat)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclickermonkey%2Fstatastic","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fclickermonkey%2Fstatastic","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclickermonkey%2Fstatastic/lists"}