Mercurial > stress-tester
changeset 550:87e1444c7bab
ReporterImpl - merge option
author | Devel 1 |
---|---|
date | Mon, 18 Sep 2017 11:09:55 +0200 |
parents | 4bdd968d121b |
children | c9a1b0be46ef |
files | stress-tester-reporter/src/main/java/com/passus/st/reporter/server/ReporterImpl.java stress-tester-reporter/src/main/java/com/passus/st/reporter/server/ServerMain.java |
diffstat | 2 files changed, 45 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/stress-tester-reporter/src/main/java/com/passus/st/reporter/server/ReporterImpl.java Fri Sep 15 11:39:04 2017 +0200 +++ b/stress-tester-reporter/src/main/java/com/passus/st/reporter/server/ReporterImpl.java Mon Sep 18 11:09:55 2017 +0200 @@ -18,18 +18,29 @@ private final PrintWriter reqFile; private final PrintWriter respFile; + private final PrintWriter reqRespFile; private final PrintWriter emitterFile; + private final boolean merge; private boolean verbose; public ReporterImpl() throws IOException { + this(false); + } + + public ReporterImpl(boolean merge) throws IOException { reqFile = new PrintWriter("requests.csv", "UTF-8"); respFile = new PrintWriter("responses.csv", "UTF-8"); + reqRespFile = merge ? new PrintWriter("all.csv", "UTF-8") : null; emitterFile = new PrintWriter("emitter.csv", "UTF-8"); + this.merge = merge; } public void close() { reqFile.close(); respFile.close(); + if (merge) { + reqRespFile.close(); + } emitterFile.close(); } @@ -111,6 +122,29 @@ printDuration(reqStart, reqStop, "req", url); printDuration(reqStop, respStart, "r2r", url); printDuration(respStart, respStop, "res", url); + + if (merge) { + addValue(builder, getValue(fields, "reqId")); + addValue(builder, getValue(fields, "clientPort")); + addValue(builder, getValue(fields, "reqStart")); + addValue(builder, getValue(fields, "reqStop")); + addValue(builder, getValue(fields, "respStart")); + addValue(builder, getValue(fields, "respStop")); + addValue(builder, String.valueOf(reqStop - reqStart)); + addValue(builder, String.valueOf(respStart - reqStop)); + addValue(builder, String.valueOf(respStop - respStart)); + addValue(builder, getValue(fields, "reqHdrSize")); + addValue(builder, getValue(fields, "reqCntSize")); + addValue(builder, getValue(fields, "respHdrSize")); + addValue(builder, getValue(fields, "respCntSize")); + addValue(builder, getValue(fields, "code")); + addValue(builder, getValue(fields, "method")); + addValue(builder, getValue(fields, "url")); + builder.setLength(builder.length() - 1); + reqRespFile.println(builder.toString()); + reqRespFile.flush(); + builder.setLength(0); + } } return "OK"; @@ -118,7 +152,7 @@ private static void printDuration(long start, long end, String name, String url) { long diff = end - start; - if (diff > 1000) { + if (diff > 600) { System.out.println("long " + name + ": " + diff + " " + url); } }
--- a/stress-tester-reporter/src/main/java/com/passus/st/reporter/server/ServerMain.java Fri Sep 15 11:39:04 2017 +0200 +++ b/stress-tester-reporter/src/main/java/com/passus/st/reporter/server/ServerMain.java Mon Sep 18 11:09:55 2017 +0200 @@ -23,7 +23,7 @@ static final int PORT = 11111; static SnmpLogger snmp; - + static void printHelp(Options options) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("[options]", "description", options, ""); @@ -51,6 +51,12 @@ .build() ); + options.addOption(option("m", "merged").desc("Write file with merged request and response data") + .hasArg(false) + .build() + ); + + boolean merge; try { CommandLine cl = new DefaultParser().parse(options, args); if (cl.hasOption("s")) { @@ -64,6 +70,8 @@ printError("Options <snmpCommunity> and <snmpPeriod> require to specify SNMP Address."); return; } + + merge = cl.hasOption("m"); } catch (ParseException ex) { System.out.println(ex.getMessage()); printHelp(options); @@ -71,7 +79,7 @@ } InetSocketAddress serverAddress = new InetSocketAddress(PORT); - ReporterImpl reporter = new ReporterImpl(); + ReporterImpl reporter = new ReporterImpl(merge); reporter.setVerbose(false); Responder responder = new SpecificResponder(Reporter.class, reporter); Server server = new NettyServer(responder, serverAddress);