Skip to content

Conversation

@timholy
Copy link
Member

@timholy timholy commented Sep 9, 2016

The main attraction of CircularDeque is its performance:

julia> using DataStructures, BenchmarkTools

julia> D = Deque{Int}()
Deque [Int64[]]

julia> C = CircularDeque{Int}(5)
CircularDeque{Int64}([])

julia> function foo!(D)
           for i = 1:5
               push!(D, i)
           end
           v = back(D)
           for i = 1:5
               shift!(D)
           end
           v
       end
foo! (generic function with 1 method)

julia> foo!(D)
5

julia> foo!(C)
5

julia> @benchmark foo!($D)
BenchmarkTools.Trial: 
  samples:          10000
  evals/sample:     870
  time tolerance:   5.00%
  memory tolerance: 1.00%
  memory estimate:  0.00 bytes
  allocs estimate:  0
  minimum time:     153.00 ns (0.00% GC)
  median time:      155.00 ns (0.00% GC)
  mean time:        156.19 ns (0.00% GC)
  maximum time:     265.00 ns (0.00% GC)

julia> @benchmark foo!($C)
BenchmarkTools.Trial: 
  samples:          10000
  evals/sample:     995
  time tolerance:   5.00%
  memory tolerance: 1.00%
  memory estimate:  0.00 bytes
  allocs estimate:  0
  minimum time:     30.00 ns (0.00% GC)
  median time:      33.00 ns (0.00% GC)
  mean time:        33.22 ns (0.00% GC)
  maximum time:     56.00 ns (0.00% GC)

@codecov-io
Copy link

codecov-io commented Sep 9, 2016

Current coverage is 92.21% (diff: 100%)

Merging #215 into master will increase coverage by 0.15%

@@             master       #215   diff @@
==========================================
  Files            27         28     +1   
  Lines          2291       2338    +47   
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
+ Hits           2109       2156    +47   
  Misses          182        182          
  Partials          0          0          

Powered by Codecov. Last update a4a2d41...4ba6e0c

REQUIRE Outdated
@@ -1 +1,3 @@
julia 0.4
Compat 0.8.5
BaseTestNext
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only a test dependency, isn't it?

useful addition though

@timholy timholy force-pushed the teh/circdeque branch 2 times, most recently from 2e8a6ec to 95faa0e Compare September 10, 2016 09:04
@timholy
Copy link
Member Author

timholy commented Sep 10, 2016

With a couple more performance optimizations, I got it down to a median of 20ns, which is almost 8 times faster than the existing Deque.

using DataStructures
using Base.Test

if VERSION >= v"0.5.0-dev+7720"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't it sufficient to just do this in the runtests.jl file?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems to have been set up so that you can also run at least some of the test files independently. For example, if I'm hacking on one particular structure, it's nice to be able to quickly run the tests for just that structure.

@timholy timholy merged commit 52615e8 into master Sep 12, 2016
@timholy timholy deleted the teh/circdeque branch September 12, 2016 01:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants