{"id":17113672,"url":"https://github.com/totakke/libra","last_synced_at":"2025-04-13T04:09:01.126Z","repository":{"id":57713879,"uuid":"97080440","full_name":"totakke/libra","owner":"totakke","description":"Benchmarking framework for Clojure","archived":false,"fork":false,"pushed_at":"2019-02-27T10:24:59.000Z","size":33,"stargazers_count":9,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-13T04:08:50.993Z","etag":null,"topics":["benchmark","boot","clojure","leiningen"],"latest_commit_sha":null,"homepage":"","language":"Clojure","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/totakke.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-07-13T04:37:47.000Z","updated_at":"2025-04-12T14:00:14.000Z","dependencies_parsed_at":"2022-08-25T10:31:04.436Z","dependency_job_id":null,"html_url":"https://github.com/totakke/libra","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/totakke%2Flibra","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/totakke%2Flibra/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/totakke%2Flibra/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/totakke%2Flibra/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/totakke","download_url":"https://codeload.github.com/totakke/libra/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248661704,"owners_count":21141450,"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":["benchmark","boot","clojure","leiningen"],"created_at":"2024-10-14T17:11:34.617Z","updated_at":"2025-04-13T04:09:01.090Z","avatar_url":"https://github.com/totakke.png","language":"Clojure","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Libra\n\n[![Clojars Project](https://img.shields.io/clojars/v/net.totakke/libra.svg)](https://clojars.org/net.totakke/libra)\n[![CircleCI](https://circleci.com/gh/totakke/libra.svg?style=svg)](https://circleci.com/gh/totakke/libra)\n\nBenchmarking framework for Clojure\n\n## Installation\n\n### Core\n\nLeiningen/Boot:\n\n```clojure\n[net.totakke/libra \"0.1.1\"]\n```\n\nClojure CLI:\n\n```clojure\nnet.totakke/libra {:mvn/version \"0.1.1\"}\n```\n\n### Tools\n\nLeiningen plugin:\n\n```clojure\n:plugins [[net.totakke/lein-libra \"0.1.2\"]]\n```\n\nBoot task:\n\n```clojure\n[net.totakke/boot-libra \"0.1.0\" :scope \"test\"]\n```\n\nCLI runner:\n\n```clojure\nnet.totakke/libra-runner {:git/url \"https://github.com/totakke/libra\"\n                          :sha \"6d2da78300438cb212b58d17675fc9e5d405ad49\"\n                          :deps/root \"libra-runner\"}\n```\n\n## Getting started\n\nLibra provides clojure.test-like functions and macros for benchmarking. For\nexample, `defbench` defines a benchmark and `run-benches` measures defined\nbenchmarks in the namespace.\n\n```clojure\n(require '[libra.bench :refer :all])\n\n(defn slow-inc [n]\n  (Thread/sleep 10)\n  (inc n))\n\n(defbench slow-inc-bench\n  (is (dur 10 (slow-inc 100))))\n\n(run-benches)\n;; Measuring user\n;;\n;; slow-inc-bench (:xx)\n;;\n;;   time: 11.725818 ms, sd: 1.073600 ms\n;;=\u003e nil\n```\n\n## Basics\n\nBasic usage is writing benchmarks in a separate directory (e.g. `bench`) from\n`src` and running them with command-line. See [example project](https://github.com/totakke/libra/tree/master/example)\nand try running benchmark.\n\nThe project consists of the following files.\n\n```\nexample/\n├── project.clj or build.boot or deps.edn\n├── src/\n│   └── example/\n│       └── core.clj\n└── bench/\n    └── example/\n        └── core_bench.clj\n```\n\nLocate your awesome codes in `src/example/core.clj` as usual, and write\nbenchmarking programs in `bench/example/core_bench.clj`.\n\n```clojure\n(ns example.core-bench\n  (:require [libra.bench :refer :all]\n            [example.core :refer :all]))\n\n(defbench primes-with-trial-div-bench\n  (is (dur 10 (doall (primes-with-trial-div 100000)))))\n\n(defbench primes-with-eratosthenes-bench\n  (is (dur 10 (doall (primes-with-eratosthenes 100000)))))\n```\n\n### With Leiningen\n\nTo run the benchmark with Leiningen,\n\n```console\n$ lein libra\n```\n\nlein-libra looks benchmark files in `bench` directory by default. You can change\nthis by placing the following in `project.clj`:\n\n```clojure\n:libra {:bench-paths [\"path/to/bench\"]}\n```\n\nYou can supply predicates to determine whether to run a benchmark or not, which\ntakes `defbench` metadata as argument:\n\n```clojure\n:libra {:bench-selectors {:default (complement :slow)\n                          :slow :slow}}\n```\n\n### With Boot\n\nTo run the benchmark with Boot,\n\n```console\n$ lein benchmarking libra\n```\n\nboot-libra provides `libra` task. Benchmark directory needs to be included in\nthe classpath, so that you should add a profile task for benchmarking:\n\n```clojure\n(require '[libra.boot :refer [libra]])\n\n(deftask benchmarking []\n  (set-env! :source-paths #(conj % \"bench\"))\n  identity)\n```\n\n### With Clojure CLI\n\nInclude a dependency on libra-runner in `deps.edn`.\n\n```clojure\n:aliases {:libra {:extra-paths [\"bench\"]\n                  :extra-deps {net.totakke/libra-runner {:git/url \"https://github.com/totakke/libra\"\n                                                         :sha \"\u003cgit commit sha\u003e\"\n                                                         :deps/root \"libra-runner\"}}\n                  :main-opts [\"-m\" \"libra.runner\"]}}\n```\n\nThen, invoke `libra` alias with CLI.\n\n```console\n$ clj -Alibra\n```\n\nYou may supply additional options:\n\n```\n-d, --dir DIR           Name of the directory containing benchmarks, default \"bench\".\n-n, --namespace SYMBOL  Symbol indicating a specific namespace to run benchmarks.\n-i, --include KEYWORD   Run only benchmarks that have this metadata keyword.\n-e, --exclude KEYWORD   Exclude benchmarks with this metadata keyword.\n```\n\n## Criterium integration\n\nLibra can be used with a famous benchmarking library, [Criterium](https://github.com/hugoduncan/criterium/).\n`libra.criterium` provides wrapper macros of Criterium.\n\n```clojure\n(require '[libra.criterium :as c])\n\n(defbench primes-with-eratosthenes-bench\n  (is (c/quick-bench (doall (primes-with-eratosthenes 100000)))))\n```\n\n## License\n\nCopyright © 2017-2019 Toshiki Takeuchi\n\nDistributed under the MIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftotakke%2Flibra","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftotakke%2Flibra","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftotakke%2Flibra/lists"}