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

Add more graph types in Graph benchmarks #931

Merged
merged 1 commit into from
Feb 12, 2023

Conversation

meooow25
Copy link
Contributor

Add star and line graphs, which are the extremes of wide and deep graphs.

We discussed adding some non-random graphs in #883, here's a couple I think are useful.

Benchmarks on GHC 9.2.5
  buildG
    rand,n=100,m=1000:       OK (4.51s)
      7.47 μs ± 332 ns,  30 KB allocated,  98 B  copied, 927 MB peak memory
    rand,n=100,m=10000:      OK (7.38s)
      99.4 μs ± 3.0 μs, 241 KB allocated, 7.0 KB copied, 927 MB peak memory
    rand,n=10000,m=100000:   OK (1.76s)
      5.79 ms ± 567 μs, 2.8 MB allocated, 884 KB copied, 927 MB peak memory
    rand,n=100000,m=1000000: OK (1.04s)
      95.0 ms ± 5.4 ms,  29 MB allocated,  44 MB copied, 938 MB peak memory
    star,n=100:              OK (4.90s)
      1.43 μs ± 101 ns, 9.4 KB allocated,   6 B  copied, 962 MB peak memory
    star,n=1000000:          OK (1.10s)
      60.4 ms ± 2.1 ms,  92 MB allocated,  43 MB copied, 976 MB peak memory
    line,n=100:              OK (4.96s)
      1.30 μs ± 127 ns, 9.4 KB allocated,   6 B  copied, 1.0 GB peak memory
    line,n=1000000:          OK (1.04s)
      64.4 ms ± 1.8 ms,  92 MB allocated,  43 MB copied, 1.0 GB peak memory
  graphFromEdges
    rand,n=100,m=1000:       OK (3.78s)
      43.9 μs ± 2.8 μs, 111 KB allocated, 449 B  copied, 1.0 GB peak memory
    rand,n=100,m=10000:      OK (2.38s)
      540  μs ±  49 μs, 853 KB allocated,  23 KB copied, 1.0 GB peak memory
    rand,n=10000,m=100000:   OK (1.22s)
      17.1 ms ± 1.6 ms,  11 MB allocated, 4.6 MB copied, 1.0 GB peak memory
    rand,n=100000,m=1000000: OK (6.85s)
      378  ms ± 6.7 ms, 108 MB allocated,  54 MB copied, 1.1 GB peak memory
    star,n=100:              OK (4.78s)
      6.87 μs ± 685 ns,  33 KB allocated,  57 B  copied, 1.3 GB peak memory
    star,n=1000000:          OK (14.78s)
      452  ms ±  17 ms, 328 MB allocated, 472 MB copied, 1.6 GB peak memory
    line,n=100:              OK (4.90s)
      6.82 μs ± 364 ns,  34 KB allocated,  53 B  copied, 1.6 GB peak memory
    line,n=1000000:          OK (16.41s)
      505  ms ± 5.0 ms, 328 MB allocated, 425 MB copied, 1.6 GB peak memory
  transposeG
    rand,n=100,m=1000:       OK (3.84s)
      7.67 μs ± 668 ns,  32 KB allocated, 106 B  copied, 1.6 GB peak memory
    rand,n=100,m=10000:      OK (3.75s)
      111  μs ± 3.2 μs, 241 KB allocated, 5.8 KB copied, 1.6 GB peak memory
    rand,n=10000,m=100000:   OK (1.76s)
      2.25 ms ± 170 μs, 3.1 MB allocated, 1.1 MB copied, 1.6 GB peak memory
    rand,n=100000,m=1000000: OK (1.18s)
      78.1 ms ± 3.5 ms,  31 MB allocated,  47 MB copied, 1.6 GB peak memory
    star,n=100:              OK (4.79s)
      1.50 μs ±  92 ns,  11 KB allocated,   3 B  copied, 1.6 GB peak memory
    star,n=1000000:          OK (1.09s)
      66.0 ms ± 1.4 ms, 106 MB allocated,  46 MB copied, 1.6 GB peak memory
    line,n=100:              OK (6.62s)
      1.39 μs ±  23 ns,  11 KB allocated,   3 B  copied, 1.6 GB peak memory
    line,n=1000000:          OK (1.03s)
      64.1 ms ± 2.3 ms, 106 MB allocated,  75 MB copied, 1.6 GB peak memory
  dfs
    rand,n=100,m=1000:       OK (4.46s)
      4.90 μs ± 352 ns, 4.7 KB allocated,   1 B  copied, 1.6 GB peak memory
    rand,n=100,m=10000:      OK (4.40s)
      47.3 μs ± 3.4 μs, 4.0 KB allocated,   2 B  copied, 1.6 GB peak memory
    rand,n=10000,m=100000:   OK (1.87s)
      1.61 ms ± 131 μs, 1.4 MB allocated,  21 KB copied, 1.6 GB peak memory
    rand,n=100000,m=1000000: OK (1.50s)
      88.1 ms ± 5.0 ms,  14 MB allocated, 7.2 MB copied, 1.6 GB peak memory
    star,n=100:              OK (6.55s)
      1.54 μs ±  73 ns, 4.8 KB allocated,   1 B  copied, 1.6 GB peak memory
    star,n=1000000:          OK (1.18s)
      76.4 ms ± 2.1 ms, 101 MB allocated,  88 MB copied, 1.6 GB peak memory
    line,n=100:              OK (5.12s)
      1.60 μs ±  93 ns, 4.8 KB allocated,   1 B  copied, 1.6 GB peak memory
    line,n=1000000:          OK (7.50s)
      196  ms ± 6.9 ms, 164 MB allocated, 202 MB copied, 1.6 GB peak memory
  dff
    rand,n=100,m=1000:       OK (4.52s)
      5.67 μs ± 367 ns,  12 KB allocated,  10 B  copied, 1.6 GB peak memory
    rand,n=100,m=10000:      OK (4.63s)
      49.8 μs ± 3.4 μs, 9.5 KB allocated,  10 B  copied, 1.6 GB peak memory
    rand,n=10000,m=100000:   OK (3.07s)
      1.78 ms ±  59 μs, 2.1 MB allocated, 110 KB copied, 1.6 GB peak memory
    rand,n=100000,m=1000000: OK (1.45s)
      97.9 ms ± 1.4 ms,  20 MB allocated,  12 MB copied, 1.6 GB peak memory
    star,n=100:              OK (4.78s)
      2.28 μs ± 189 ns,  12 KB allocated,  10 B  copied, 1.6 GB peak memory
    star,n=1000000:          OK (0.67s)
      115  ms ± 6.9 ms, 168 MB allocated, 129 MB copied, 1.6 GB peak memory
    line,n=100:              OK (4.86s)
      2.35 μs ± 189 ns,  12 KB allocated,  10 B  copied, 1.6 GB peak memory
    line,n=1000000:          OK (5.15s)
      276  ms ±  23 ms, 233 MB allocated, 283 MB copied, 1.6 GB peak memory
  topSort
    rand,n=100,m=1000:       OK (4.22s)
      6.44 μs ± 338 ns,  20 KB allocated,  16 B  copied, 1.6 GB peak memory
    rand,n=100,m=10000:      OK (4.13s)
      46.2 μs ± 3.0 μs,  17 KB allocated,  25 B  copied, 1.6 GB peak memory
    rand,n=10000,m=100000:   OK (2.22s)
      1.84 ms ±  87 μs, 2.6 MB allocated, 187 KB copied, 1.6 GB peak memory
    rand,n=100000,m=1000000: OK (1.55s)
      96.2 ms ± 2.1 ms,  26 MB allocated,  19 MB copied, 1.6 GB peak memory
    star,n=100:              OK (4.23s)
      3.04 μs ± 187 ns,  20 KB allocated,  21 B  copied, 1.6 GB peak memory
    star,n=1000000:          OK (4.41s)
      228  ms ± 5.7 ms, 246 MB allocated, 293 MB copied, 1.6 GB peak memory
    line,n=100:              OK (5.23s)
      3.21 μs ± 217 ns,  20 KB allocated,  24 B  copied, 1.6 GB peak memory
    line,n=1000000:          OK (6.37s)
      361  ms ±  18 ms, 286 MB allocated, 515 MB copied, 1.6 GB peak memory
  scc
    rand,n=100,m=1000:       OK (4.06s)
      16.3 μs ± 1.4 μs,  50 KB allocated, 178 B  copied, 1.6 GB peak memory
    rand,n=100,m=10000:      OK (3.15s)
      153  μs ±  12 μs, 255 KB allocated, 7.5 KB copied, 1.6 GB peak memory
    rand,n=10000,m=100000:   OK (2.01s)
      10.8 ms ± 1.1 ms, 6.5 MB allocated, 1.8 MB copied, 1.6 GB peak memory
    rand,n=100000,m=1000000: OK (2.54s)
      221  ms ± 3.2 ms,  66 MB allocated,  77 MB copied, 1.6 GB peak memory
    star,n=100:              OK (4.09s)
      5.47 μs ± 397 ns,  29 KB allocated,  26 B  copied, 1.6 GB peak memory
    star,n=1000000:          OK (3.62s)
      446  ms ± 1.6 ms, 393 MB allocated, 529 MB copied, 1.6 GB peak memory
    line,n=100:              OK (4.22s)
      5.29 μs ± 347 ns,  29 KB allocated,  27 B  copied, 1.6 GB peak memory
    line,n=1000000:          OK (14.97s)
      451  ms ± 6.3 ms, 393 MB allocated, 564 MB copied, 1.6 GB peak memory
  bcc
    rand,n=100,m=1000:       OK (3.82s)
      14.7 μs ± 1.0 μs,  44 KB allocated,  57 B  copied, 1.6 GB peak memory
    rand,n=100,m=10000:      OK (4.19s)
      107  μs ± 5.3 μs,  43 KB allocated,  81 B  copied, 1.6 GB peak memory
    rand,n=10000,m=100000:   OK (2.12s)
      4.12 ms ± 176 μs, 5.8 MB allocated, 585 KB copied, 1.6 GB peak memory
    rand,n=100000,m=1000000: OK (0.99s)
      208  ms ± 8.2 ms,  57 MB allocated,  35 MB copied, 1.6 GB peak memory
    star,n=100:              OK (5.35s)
      6.61 μs ± 338 ns,  39 KB allocated,  36 B  copied, 1.6 GB peak memory
    star,n=1000000:          OK (13.04s)
      378  ms ±  22 ms, 437 MB allocated, 417 MB copied, 1.6 GB peak memory
    line,n=100:              OK (4.74s)
      7.87 μs ± 699 ns,  48 KB allocated,  67 B  copied, 1.6 GB peak memory
    line,n=1000000:          OK (27.29s)
      830  ms ±  44 ms, 687 MB allocated, 1.0 GB copied, 1.8 GB peak memory
  stronglyConnCompR
    rand,n=100,m=1000:       OK (3.93s)
      78.3 μs ± 7.5 μs, 170 KB allocated, 1.3 KB copied, 1.8 GB peak memory
    rand,n=100,m=10000:      OK (3.23s)
      850  μs ±  60 μs, 1.1 MB allocated,  65 KB copied, 1.8 GB peak memory
    rand,n=10000,m=100000:   OK (0.93s)
      34.5 ms ± 1.4 ms,  18 MB allocated,  11 MB copied, 1.8 GB peak memory
    rand,n=100000,m=1000000: OK (6.34s)
      782  ms ± 3.2 ms, 182 MB allocated, 142 MB copied, 1.8 GB peak memory
    star,n=100:              OK (3.56s)
      17.8 μs ± 1.7 μs,  71 KB allocated, 183 B  copied, 1.8 GB peak memory
    star,n=1000000:          OK (16.36s)
      1.021 s ±  50 ms, 798 MB allocated, 1.0 GB copied, 1.8 GB peak memory
    line,n=100:              OK (3.93s)
      18.1 μs ± 1.5 μs,  71 KB allocated, 180 B  copied, 1.8 GB peak memory
    line,n=1000000:          OK (31.73s)
      0.997 s ±  48 ms, 798 MB allocated, 1.0 GB copied, 1.8 GB peak memory

Add star and line graphs, which are the extremes of wide and deep
graphs.
@treeowl treeowl merged commit fa1d1e7 into haskell:master Feb 12, 2023
@treeowl
Copy link
Contributor

treeowl commented Feb 12, 2023

Awesome. Would there be any value in having a maximal DAG case, where there's an edge from $m$ to $n$ if and only if $m < n$?

@meooow25
Copy link
Contributor Author

I can't of think of anything in particular, at least not in the way of this PR, where deep is the worst case of recursive depth with a fixed number of nodes and wide the best case. The tree from your DAG would also be a line from 1 to n, but n needs to be much smaller since the number edges would be $O(n^2)$.

But I don't see any harm in having it, I'll implement it and see if any interesting properties show up.

@meooow25 meooow25 deleted the graph-bench branch March 4, 2023 18:13
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.

None yet

2 participants