Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added properties and propertyvalues iterators #61

Merged
merged 2 commits into from
Jul 3, 2019

Conversation

rofinn
Copy link
Collaborator

@rofinn rofinn commented Jul 2, 2019

This is pretty similar to #46 and has similar performance characteristics (e.g., faster with mixed value types at the cost of being slower when the value types are all the same).

@iamed2
Copy link
Contributor

iamed2 commented Jul 2, 2019

Can you post the benchmark comparisons here for future reference?

@rofinn
Copy link
Collaborator Author

rofinn commented Jul 2, 2019

julia> using BenchmarkTools, IterTools
[ Info: Recompiling stale cache file /Users/rory/.julia/compiled/v1.0/IterTools/hhnii.ji for IterTools [c8e1da08-722c-5040-9ed9-7db0dc04731e]

julia> f1(x) = ((n, getproperty(x, n)) for n in propertynames(x))
f1 (generic function with 1 method)

julia> f2(x) = properties(x)
f2 (generic function with 1 method)

julia> v = (a = 1, b = nothing, c = "foo")
(a = 1, b = nothing, c = "foo")

julia> @benchmark collect(f1($v))
BenchmarkTools.Trial:
  memory estimate:  704 bytes
  allocs estimate:  14
  --------------
  minimum time:     3.761 μs (0.00% GC)
  median time:      3.933 μs (0.00% GC)
  mean time:        4.532 μs (9.43% GC)
  maximum time:     3.364 ms (99.76% GC)
  --------------
  samples:          10000
  evals/sample:     8

julia> @benchmark collect(f2($v))
BenchmarkTools.Trial:
  memory estimate:  384 bytes
  allocs estimate:  10
  --------------
  minimum time:     2.614 μs (0.00% GC)
  median time:      2.723 μs (0.00% GC)
  mean time:        2.918 μs (2.97% GC)
  maximum time:     871.587 μs (99.37% GC)
  --------------
  samples:          10000
  evals/sample:     9

julia> v = (a = 1, c = 2.5)
(a = 1, c = 2.5)

julia> @benchmark collect(f1($v))
BenchmarkTools.Trial:
  memory estimate:  720 bytes
  allocs estimate:  15
  --------------
  minimum time:     4.800 μs (0.00% GC)
  median time:      5.049 μs (0.00% GC)
  mean time:        5.728 μs (8.95% GC)
  maximum time:     4.027 ms (99.73% GC)
  --------------
  samples:          10000
  evals/sample:     7

julia> @benchmark collect(f2($v))
BenchmarkTools.Trial:
  memory estimate:  432 bytes
  allocs estimate:  12
  --------------
  minimum time:     1.962 μs (0.00% GC)
  median time:      2.199 μs (0.00% GC)
  mean time:        2.661 μs (13.79% GC)
  maximum time:     2.885 ms (99.83% GC)
  --------------
  samples:          10000
  evals/sample:     10

julia> v = (a = 1, c = 2)
(a = 1, c = 2)

julia> @benchmark collect(f1($v))
BenchmarkTools.Trial:
  memory estimate:  288 bytes
  allocs estimate:  7
  --------------
  minimum time:     274.668 ns (0.00% GC)
  median time:      282.671 ns (0.00% GC)
  mean time:        318.753 ns (7.93% GC)
  maximum time:     103.501 μs (99.61% GC)
  --------------
  samples:          10000
  evals/sample:     301

julia> @benchmark collect(f2($v))
BenchmarkTools.Trial:
  memory estimate:  416 bytes
  allocs estimate:  11
  --------------
  minimum time:     1.836 μs (0.00% GC)
  median time:      1.919 μs (0.00% GC)
  mean time:        2.077 μs (3.74% GC)
  maximum time:     779.612 μs (99.59% GC)
  --------------
  samples:          10000
  evals/sample:     10

Copy link
Contributor

@iamed2 iamed2 left a comment

Choose a reason for hiding this comment

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

Looks good, please add docs now :)

test/runtests.jl Show resolved Hide resolved
src/IterTools.jl Outdated Show resolved Hide resolved
src/IterTools.jl Show resolved Hide resolved
@codecov-io
Copy link

codecov-io commented Jul 2, 2019

Codecov Report

Merging #61 into master will decrease coverage by 1.35%.
The diff coverage is 92.85%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #61      +/-   ##
==========================================
- Coverage   66.66%   65.31%   -1.36%     
==========================================
  Files           1        1              
  Lines         246      222      -24     
==========================================
- Hits          164      145      -19     
+ Misses         82       77       -5
Impacted Files Coverage Δ
src/IterTools.jl 65.31% <92.85%> (-1.36%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update acb368c...6e3619a. Read the comment docs.

@iamed2
Copy link
Contributor

iamed2 commented Jul 3, 2019

Please add the docstrings to docs/src/index.md

@iamed2 iamed2 merged commit a2e4d09 into JuliaCollections:master Jul 3, 2019
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.

3 participants