Skip to content

Instantly share code, notes, and snippets.

@heliosdrm
Created February 3, 2020 00:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save heliosdrm/e242ab6c3e035af72e4d70c521c187b3 to your computer and use it in GitHub Desktop.
Save heliosdrm/e242ab6c3e035af72e4d70c521c187b3 to your computer and use it in GitHub Desktop.
Comparison of GRUtils and GR plotting times
using BenchmarkTools
times = Dict{String, Float64}()
times["using"] = @elapsed using GR
# times["using"] = @elapsed using GRUtils
x = LinRange(-2, 2, 40)
y = x.^3 .+ x.^2 .+ x .+ 6
times["plot_first"] = @elapsed plot(x, y);
times["plot"] = @belapsed plot(x, y);
# times["plot_draw"] = @belapsed draw($(gcf()))
times["stem_first"] = @elapsed stem(x, y);
times["stem"] = @belapsed stem(x, y);
# times["stem_draw"] = @belapsed draw($(gcf()))
x = LinRange(0, 1, 11)
y = LinRange(0, 1, 11)
s = LinRange(50, 400, 11)
c = LinRange(0, 255, 11)
times["scatter_first"] = @elapsed scatter(x, y, s, c);
times["scatter"] = @belapsed scatter(x, y, s, c);
# times["scatter_draw"] = @belapsed draw($(gcf()))
x = LinRange(0, 30, 1000)
y = cos.(x) .* x
z = sin.(x) .* x
times["plot3_first"] = @elapsed plot3(x, y, z);
times["plot3"] = @belapsed plot3(x, y, z);
# times["plot3_draw"] = @belapsed draw($(gcf()))
x = 2 .* rand(100) .- 1
y = 2 .* rand(100) .- 1
z = 2 .* rand(100) .- 1
c = 999 .* rand(100) .+ 1
times["scatter3_first"] = @elapsed scatter3(x, y, z, c);
times["scatter3"] = @belapsed scatter3(x, y, z, c);
# times["scatter3_draw"] = @belapsed draw($(gcf()))
angles = LinRange(0, 360, 40)
radii = LinRange(0, 2, 40)
times["polar_first"] = @elapsed polar(angles, radii);
times["polar"] = @belapsed polar(angles, radii);
# times["polar_draw"] = @belapsed draw($(gcf()))
numbers = [10, 15, 35, 20]
times["barplot_first"] = @elapsed barplot(numbers);
times["barplot"] = @belapsed barplot(numbers);
# times["barplot_draw"] = @belapsed draw($(gcf()))
data = 2 .* randn(100) .- 1
times["histogram_first"] = @elapsed histogram(data, nbins=19);
times["histogram"] = @belapsed polarhistogram(data, nbins = 19);
# times["histogram_draw"] = @belapsed draw($(gcf()))
x = 8 .* rand(100) .- 4
y = 8 .* rand(100) .- 4
z = sin.(x) + cos.(y)
times["contour_first"] = @elapsed contour(x, y, z);
times["contour"] = @belapsed contour(x, y, z);
# times["contour_draw"] = @belapsed draw($(gcf()))
times["contourf_first"] = @elapsed contourf(x, y, z);
times["contourf"] = @belapsed contourf(x, y, z);
# times["contourf_draw"] = @belapsed draw($(gcf()))
times["surface_first"] = @elapsed surface(x, y, z);
times["surface"] = @belapsed surface(x, y, z);
# times["surface_draw"] = @belapsed draw($(gcf()))
times["tricont_first"] = @elapsed tricont(x, y, z);
times["tricont"] = @belapsed tricont(x, y, z);
# times["tricont_draw"] = @belapsed draw($(gcf()))
times["trisurf_first"] = @elapsed trisurf(x, y, z);
times["trisurf"] = @belapsed trisurf(x, y, z);
# times["trisurf_draw"] = @belapsed draw($(gcf()))
x = LinRange(-2, 2, 40)
y = LinRange(0, pi, 20)
z = sin.(x') .+ cos.(y)
times["heatmap_first"] = @elapsed heatmap(z);
times["heatmap"] = @belapsed heatmap(z);
# times["heatmap_draw"] = @belapsed draw($(gcf()))
x = LinRange(-3, 3, 150)
y = LinRange(-2, 2, 100)
data = (sin.(exp.(x'.^2 .+ y.^2)) .+ sin.(x') .+ cos.(y) .+ 3) ./ 6
times["imshow_first"] = @elapsed imshow(data);
times["imshow"] = @belapsed imshow(data);
# times["imshow_draw"] = @belapsed draw($(gcf()))
x = randn(100_000)
y = randn(100_000)
times["hexbin_first"] = @elapsed hexbin(x, y);
times["hexbin"] = @belapsed hexbin(x, y);
# times["hexbin_draw"] = @belapsed draw($(gcf()))
action GR_REPL GRUtils_REPL GR_Atom GRUtils_Atom
using 0.223680613 0.285953417 0.491525951 0.623560722
plot 0.000137675 0.000037229 0.000889395 0.000040197
plot_draw 0.000137675 0.0001202 0.000889395 0.000849945
plot_first 6.315205215 4.946901938 5.765720028 4.430257237
stem 0.000172679 0.000044116 0.001133914 0.000047646
stem_draw 0.000172679 0.093184116 0.001133914 0.001070508
stem_first 0.200612605 1.135229505 0.205703633 0.964751636
scatter 0.000168175 0.000047914 0.001011698 0.000051283
scatter_draw 0.000168175 0.000163957 0.001011698 0.017981097
scatter_first 0.903966687 1.416969341 0.764924316 1.315263101
plot3 0.00028212 0.000063761 0.002413806 0.000068417
plot3_draw 0.00028212 0.000244047 0.002413806 0.002330079
plot3_first 0.597078723 1.262999668 0.55143241 1.267135936
scatter3 0.000418588 0.000050095 0.00184349 0.000052571
scatter3_draw 0.000172679 0.000345688 0.001133914 0.018721189
scatter3_first 0.629594002 0.9778866 0.719262273 0.976399687
polar 0.000351449 0.000041613 0.004433683 0.000043473
polar_draw 0.000351449 0.000338987 0.004433683 0.004889358
polar_first 0.935242463 0.698529356 0.793391509 0.69840062
barplot 0.000144184 0.000079509 0.000716022 0.000084296
barplot_draw 0.000144184 0.000176783 0.000716022 0.000728754
barplot_first 0.596450268 1.667386365 0.537536099 1.65535172
histogram 0.000453789 0.000044022 0.003787628 0.000047001
histogram_draw 0.000453789 0.000503591 0.003787628 0.00732146
histogram_first 0.630497107 0.587495007 0.679965572 0.407321093
contour 0.022472762 0.003549253 0.040419438 0.003542384
contour_draw 0.022472762 0.020019023 0.040419438 0.04810037
contour_first 0.589160599 1.52636179 0.700398462 1.591968656
contourf 0.025655879 0.003551567 0.071579096 0.003546062
contourf_draw 0.025655879 0.025841751 0.071579096 0.079651204
contourf_first 0.0600038 1.097375617 0.156548324 1.141655789
surface 0.006535595 0.002596929 0.181782569 0.002587093
surface_draw 0.006535595 0.00709447 0.181782569 0.224208736
surface_first 0.10076005 1.319987449 0.349841764 1.372037428
tricont 0.0007994 0.000053078 0.003595689 0.000054815
tricont_draw 0.0007994 0.000803592 0.003595689 0.020005941
tricont_first 0.036397848 0.964567816 0.096189964 1.049844137
trisurf 0.000763002 0.05352 0.012406126 0.000057479
trisurf_draw 0.000763002 0.05416591 0.012406126 0.020687864
trisurf_first 0.037272114 0.602135149 0.061864082 0.53061514
heatmap 0.000284836 0.000047068 0.183028549 0.000049807
heatmap_draw 0.000284836 0.000176249 0.183028549 0.193945573
heatmap_first 0.594620311 1.270289884 0.802287037 1.235813156
hexbin 0.004028971 0.000537244 0.026483921 0.000551533
hexbin_draw 0.000453789 0.003836346 0.003787628 0.035808649
hexbin_first 0.511794474 0.978538261 0.614035381 0.970469035
imshow 0.004688416 0.213681317 0.191214886 0.227617972
imshow_draw 0.004688416 0.213777299 0.191214886 0.429620427
imshow_first 0.426803897 2.120557879 0.566177173 1.984228983
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment