Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/palisades-lakes/faster-multimethods
Almost backwards compatible alternative to Clojure 1.8.0 implementation of multimethods with roughly 1/10 the method lookup cost.
https://github.com/palisades-lakes/faster-multimethods
benchmark clojure multimethods
Last synced: 3 months ago
JSON representation
Almost backwards compatible alternative to Clojure 1.8.0 implementation of multimethods with roughly 1/10 the method lookup cost.
- Host: GitHub
- URL: https://github.com/palisades-lakes/faster-multimethods
- Owner: palisades-lakes
- License: apache-2.0
- Created: 2017-08-08T00:52:06.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2023-08-01T19:03:36.000Z (over 1 year ago)
- Last Synced: 2024-08-10T10:01:09.383Z (6 months ago)
- Topics: benchmark, clojure, multimethods
- Language: Java
- Homepage:
- Size: 1.86 MB
- Stars: 12
- Watchers: 0
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# faster-multimethods
[![Clojars Project](https://img.shields.io/clojars/v/palisades-lakes/faster-multimethods.svg)](https://clojars.org/palisades-lakes/faster-multimethods)
Alternative to the
Clojure 1.8.0 implementation of generic functions (aka multimethods)
via `defmulti`/`defmethod`/`MultiFn`.Very roughly 1/10 the cost for method lookup of Clojure 1.8.0,
and comparable in performance to using protocols, while being
fully dynamic.Brief benchmark discussion is in [benchmarks](docs/benchmarks.md)
A change history, including differences from Clojure 1.8.0,
is in [changes](docs/changes.md).## Dependency
### Maven:
```xml
palisades-lakes
faster-multimethods
0.1.0```
### Leiningen/Boot:
```clojure
[palisades-lakes/faster-multimethods "0.1.0"]
```## Code examples
### Fastest:
```clojure
(require `[palisades.lakes.multimethods.core :as plm])(plm/defmulti intersects?
"Test for general set intersection."
{}
plm/signature
:hierarchy false)
(plm/defmethod intersects?
(plm/to-signature IntegerInterval java.util.Set)
[^IntegerInterval s0 ^java.util.Set s1]
(.intersects s0 s1))
...
```### Most general:
```clojure
(require `[palisades.lakes.multimethods.core :as plm])(plm/defmulti intersects?
"Test for general set intersection."
{}
(fn intersects?-dispatch [s0 s1] [(class s0) (class s1))))
(plm/defmethod intersects?
[IntegerInterval java.util.Set]
[^IntegerInterval s0 ^java.util.Set s1]
(some #(.contains s0 %) s1))
...
```## Acknowledgments
### ![Yourkit](https://www.yourkit.com/images/yklogo.png)
YourKit is kindly supporting open source projects with its full-featured Java
Profiler.YourKit, LLC is the creator of innovative and intelligent tools for profiling
Java and .NET applications. Take a look at YourKit's leading software products: