Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add memgraph lib

  • Loading branch information...
commit bd3147da83855bc63578d29199075e4971aaf3fa 1 parent 88471b6
@Vagabond authored
Showing with 68 additions and 6 deletions.
  1. +25 −6 run.sh
  2. +43 −0 src/memgraph.erl
View
31 run.sh
@@ -1,9 +1,13 @@
#!/bin/sh
-for BENCH in el_file sync_el_file lager_file log4erl_file elog_file elogger_file fast_log_file alog_file; do
- for FMT in simple small large; do
+FMTS="simple small"
+ITERATIONS=100000
+
+for FMT in $FMTS; do
+ for BENCH in el_file sync_el_file lager_file log4erl_file elog_file elogger_file fast_log_file alog_file; do
for I in 1 2 3; do
- ./bin/bench $BENCH $FMT 10000 1
+ ./bin/bench $BENCH $FMT $ITERATIONS 1
+ sleep 5
done
done
done
@@ -12,10 +16,24 @@ mv results results.1
mkdir mem_results.1
mv *.rrd *.png mem_results.1
-for BENCH in el_file sync_el_file lager_file log4erl_file elog_file elogger_file fast_log_file alog_file; do
- for FMT in simple small large; do
+for FMT in $FMTS; do
+ for BENCH in el_file sync_el_file lager_file log4erl_file elog_file elogger_file fast_log_file alog_file; do
+ for I in 1 2 3; do
+ ./bin/bench $BENCH $FMT $ITERATIONS 10
+ sleep 5
+ done
+ done
+done
+
+mv results results.10
+mkdir mem_results.10
+mv *.rrd *.png mem_results.10
+
+for FMT in $FMTS; do
+ for BENCH in el_file sync_el_file lager_file log4erl_file elog_file elogger_file fast_log_file alog_file; do
for I in 1 2 3; do
- ./bin/bench $BENCH $FMT 10000 10
+ ./bin/bench $BENCH $FMT $ITERATIONS 100
+ sleep 5
done
done
done
@@ -24,3 +42,4 @@ mv results results.100
mkdir mem_results.100
mv *.rrd *.png mem_results.100
+
View
43 src/memgraph.erl
@@ -0,0 +1,43 @@
+-module(memgraph).
+
+-include_lib("errd/include/errd.hrl").
+
+-export([start/0, start/1, init/1, graph/0, graph/2]).
+
+start() ->
+ spawn(?MODULE, init, ["memgraph"]).
+
+start(Name) ->
+ spawn(?MODULE, init, [Name]).
+
+init(Name) ->
+ FileName = Name++".rrd",
+ file:delete(FileName),
+ {ok, RRD} = errd_server:start_link(),
+ {ok, _} = errd_server:command(RRD,
+ #rrd_create{file=FileName,
+ step=1,
+ ds_defs = [#rrd_ds{name=Name, args="10:0:U", type = gauge}],
+ rra_defs = [
+ #rrd_rra{cf=last, args="0.5:1:3600"}
+ ]}),
+ self() ! update,
+ loop(RRD, Name).
+
+loop(RRD, Name) ->
+ FileName = Name++".rrd",
+ receive
+ update ->
+ Mem = erlang:memory(total),
+ errd_server:command(RRD, #rrd_update{file=FileName, updates=[#rrd_ds_update{name=Name, value=Mem}]}),
+ erlang:send_after(1000, self(), update)
+ end,
+ loop(RRD, Name).
+
+graph() ->
+ graph("memgraph", "-20m").
+
+graph(Start, Name) ->
+ {ok, RRD} = errd_server:start_link(),
+ Command = "graph "++Name++".png --start "++Start++" --imgformat PNG --height 200 --width 600 DEF:"++Name++"="++Name++".rrd:"++Name++":LAST LINE2:"++Name++"#000000:"++Name++"\n",
+ errd_server:raw(RRD, Command).

1 comment on commit bd3147d

@josevalim

Thanks!

Please sign in to comment.
Something went wrong with that request. Please try again.