Skip to content

Commit

Permalink
move to derniercri repo
Browse files Browse the repository at this point in the history
  • Loading branch information
laibulle committed Mar 20, 2017
1 parent 4f03816 commit 9c390e7
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 18 deletions.
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Slap

[![Build Status](https://travis-ci.org/laibulle/slap.svg?branch=master)](https://travis-ci.org/laibulle/slap)
[![Build Status](https://travis-ci.org/derniercri/slap.svg?branch=master)](https://travis-ci.org/derniercri/slap)

Slap is a load testing tool for developers.

Expand All @@ -16,9 +16,8 @@ __TODO__
- Parse CLI arguments
- Documentation

![Report](https://raw.githubusercontent.com/laibulle/slap/master/doc/bar.png)

![Plot](https://raw.githubusercontent.com/laibulle/slap/master/doc/plot.png)
![Report](https://raw.githubusercontent.com/derniercri/slap/master/doc/bar.png)
![Plot](https://raw.githubusercontent.com/derniercri/slap/master/doc/plot.png)


## Getting started
Expand Down
12 changes: 8 additions & 4 deletions lib/slap.ex
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ defmodule Slap do

# Stop the test
Quantum.delete_job(:ticker)
:timer.sleep(3000); # Waiting for requests to finish, assuming it would take at most 3 seconds
GenServer.cast(reporter_id, :stop)
:timer.sleep(3 * 1000) # TODO: should be replaced by someting that wait for all requests to be finished

# Run the clean up function
Scene.after_run(run_args, data)
Expand All @@ -40,7 +41,10 @@ defmodule Slap do
end

def draw_report(reporter_id) do
Slap.ReporterCli.print(GenServer.call(reporter_id, :compute))
case GenServer.call reporter_id, :running do
true -> Slap.ReporterCli.print(GenServer.call(reporter_id, :compute))
false -> -1
end
:timer.sleep(1000);
draw_report(reporter_id)
end
Expand All @@ -65,10 +69,10 @@ defmodule Slap do
{:ok, script} = File.read scene # Parse the script file
{:ok, reporter_id} = init # Start a GenServer to handle the data report
spawn(fn -> draw_report(reporter_id) end)
report = run(duration, clients, script, custom_args, reporter_id)
report = run(duration, clients, script, custom_args, reporter_id)
Slap.ReporterCli.print report # Print report into HTML
Slap.ReporterHTML.print report # Print report into HTML
IO.puts "\nYou can open an HTML report with `open report.html`"

_ -> IO.puts "Invalid arguments\n Exemple: slap examples/scene1.exs 10 10 --custom_arg1 32"
end
end
Expand Down
11 changes: 10 additions & 1 deletion lib/slap/reporter.ex
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,19 @@ defmodule Slap.Reporter do
average_latency: 0,
total_time: 0,
total_iterations: 0,
current_iteration: 0
current_iteration: 0,
running: true
}}
end

def handle_cast({:push, metrics}, state) do
{:noreply, concat(metrics, state)}
end

def handle_cast(:stop, state) do
{:noreply, %{state | running: false}}
end

def handle_cast({:set_iterations, iterations}, state) do
{:noreply, %{state | total_iterations: iterations}}
end
Expand All @@ -45,6 +50,10 @@ defmodule Slap.Reporter do
state
end

def handle_call(:running, _from, state) do
{:reply, state.running, state}
end

def handle_call(:compute, _from, state) do
{:reply, compute(state), state}
end
Expand Down
14 changes: 5 additions & 9 deletions lib/slap/reporter_cli.ex
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,15 @@ defmodule Slap.ReporterCli do

if report.total_iterations > 0 do
IO.write "\e[1A"
ProgressBar.render(report.current_iteration, report.total_iterations, format)
IO.write "\n"
IO.write "\r"
clean(80)
IO.write "\r"
write(report)
IO.write "\n"
ProgressBar.render(report.current_iteration, report.total_iterations, format)
end
end

def print(report) do
IO.write "\r"
clean(80)
IO.write "\r"
write(report)
end

def clean(0) do
end

Expand Down

0 comments on commit 9c390e7

Please sign in to comment.