Skip to content

Instantly share code, notes, and snippets.

@devstopfix
Created December 3, 2019 10:49
Show Gist options
  • Save devstopfix/f06399e1aa7486d71ddb0d2b2a0f8162 to your computer and use it in GitHub Desktop.
Save devstopfix/f06399e1aa7486d71ddb0d2b2a0f8162 to your computer and use it in GitHub Desktop.
String processing
dataset =
[
[lang: "C", loc: 79, t: {4, :s}, mem: {40, :MB}],
[lang: "Python", loc: 11, t: {4, :s}, mem: {150, :MB}],
[lang: "Ruby", loc: 9, t: {17, :s}, mem: {3, :GB}],
[lang: "Elixir", loc: 11, t: {120, :s}, mem: {700, :MB}],
[lang: "Elixir ETS", loc: 17, t: {40, :s}, mem: {730, :MB}],
[lang: "Elixir Regex", loc: 17, t: {70, :s}, mem: {730, :MB}],
[lang: "Elixir String.split", loc: 11, t: {30, :s}, mem: {730, :MB}],
[lang: "Elixir String.split pre-compiled", loc: 17, t: {29, :s}, mem: {730, :MB}],
[lang: "Elixir IO.binstream", loc: 18, t: {22, :s}, mem: {730, :MB}],
[lang: "Elixir split once", loc: 18, t: {16, :s}, mem: {4.5, :GB}],
[lang: "Elixir IO Lists", loc: 18, t: {13, :s}, mem: {5, :GB}],
[lang: "Elixir Concurrency", loc: 18, t: {13, :s}, mem: {3.5, :GB}],
[lang: "Elixir Async", loc: 18, t: {7, :s}, mem: {1.2, :GB}]
]
elapsed = dataset |> Enum.map(fn [lang: lang, loc: _, t: {t, :s}, mem: _] -> [lang, t] end)
IO.inspect(elapsed)
Gnuplot.plot([
[:set, :title, "String processing"],
[:set, :xlabel, "Tech"],
[:set, :ylabel, "Elapsed (s)"],
[:set, :term, :png, :size, '2048,1920', :font, "/Library/Fonts/FiraCode-Medium.ttf", 12],
[:set, :output, "/tmp/strings.png"],
Gnuplot.plots([
["-", :title, "Clojure GUI", :with, :lines, :ls, 1]])
], [elapsed])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment