jtomschroeder / crystalline Goto Github PK
View Code? Open in Web Editor NEWA collection of containers & algorithms for the Crystal programming language
License: MIT License
A collection of containers & algorithms for the Crystal programming language
License: MIT License
So I tried to benchmark the priority queue against my own queue with the following code to benchmark the code in this repo, and I find the results I get pretty strange.
require "benchmark"
require "./priority_queue"
values = 100_000.times.map { rand(100_000_000) }.to_a
Benchmark.bm do |x|
queue = PriorityQueue(Int32).new
x.report("crystalline - push") {
values.each do |v|
queue.push(v, v)
end
}
x.report("crystalline - pop") {
values.size.times do |v|
queue.pop
end
}
puts queue.size
queue2 = PriorityQueue(Int32).new
x.report("crystalline - mixed") {
values.each_with_index do |v, i|
queue2.push(v, v)
if i % 4 == 0
queue2.pop
end
end
}
puts queue2.size
end
This outputs
linus@donk:~/prog/pairing_heap$ crystal run src/benchmark.cr --release --no-debug
0
0
user system total real
crystalline - push 55.120000 1.290000 56.410000 ( 36.032381)
crystalline - pop 0.440000 0.000000 0.440000 ( 0.261351)
crystalline - mixed 0.120000 0.000000 0.120000 ( 0.069474)
The disconnect between push
and mixed
is pretty staggering.
For the record, my queue is at https://github.com/yxhuvud/pairing_heap/blob/master/src/priority_queue.cr . It is faster but has slightly different semantics(it picks the least number for starters) and other method names, but it could be interesting to compare against.
While I can lock this library to a particular SHA in my shard.yml
, it'd be nice to have a shard.yml
with a version so that there can be some semblance of semver throughout the project lifetime.
Thanks for making a great collection!
A>
I am in need of an Ordered Set and am planning to implement one from this library implementation of Red Black tree.
As such to avoid code duplication, I will reimplement the RB Tree Map as an RB Set of pairs. What do you think of it?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.