Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dm3/stopwatch
A Clojure/script stopwatch
https://github.com/dm3/stopwatch
clj cljs clock clojure clojurescript library stopwatch timer
Last synced: 24 days ago
JSON representation
A Clojure/script stopwatch
- Host: GitHub
- URL: https://github.com/dm3/stopwatch
- Owner: dm3
- Created: 2017-06-18T18:37:56.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2022-06-16T12:59:53.000Z (over 2 years ago)
- Last Synced: 2024-09-29T21:04:02.779Z (about 1 month ago)
- Topics: clj, cljs, clock, clojure, clojurescript, library, stopwatch, timer
- Language: Clojure
- Size: 8.79 KB
- Stars: 5
- Watchers: 3
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# stopwatch
[![Build Status](https://travis-ci.org/dm3/stopwatch.png?branch=master)](https://travis-ci.org/dm3/stopwatch)
A Clojure/script stopwatch implementation.
Uses `System/nanoTime` on the JVM.
Uses the most precise mechanism depending on the Javascript runtime:
* [Performance.now](https://developer.mozilla.org/en-US/docs/Web/API/Performance/now)
* [process.hrtime](https://nodejs.org/api/process.html#process_process_hrtime_time)
* [js/Date](https://docs.microsoft.com/en-us/scripting/javascript/reference/date-object-javascript)## Usage
Add the following dependency to your project.clj or build.boot:
```clojure
[dm3/stopwatch "0.1.1"]
```then require the namespace:
```clojure
(require '[stopwatch.core :as stopwatch])
```Using synchronously:
```clojure
(let [elapsed (stopwatch/start)]
(do-work)
(println "Elapsed: " (elapsed) "ns"))
```and asynchronously, using core.async:
```clojure
(let [elapsed (stopwatch/start)]
(go
(