Skip to content

Commit d8e1a5a

Browse files
committed
Add event loop benchmark escript wrapper
1 parent 6f7520d commit d8e1a5a

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

examples/bench_event_loop.erl

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env escript
2+
%% -*- erlang -*-
3+
%%! -pa _build/default/lib/erlang_python/ebin
4+
5+
%%% @doc Benchmark script for event loop performance.
6+
%%%
7+
%%% Run with:
8+
%%% rebar3 compile && escript examples/bench_event_loop.erl
9+
10+
-mode(compile).
11+
12+
main(_Args) ->
13+
{ok, _} = application:ensure_all_started(erlang_python),
14+
{ok, _} = py:start_contexts(),
15+
16+
Code = <<"exec(open('examples/benchmark_event_loop.py').read())">>,
17+
case py:exec(Code) of
18+
ok -> ok;
19+
{error, E} -> io:format("Error: ~p~n", [E])
20+
end,
21+
22+
halt(0).

0 commit comments

Comments
 (0)