Java Code Examples for org.apache.jmeter.samplers.SampleResult#latencyEnd()
The following examples show how to use
org.apache.jmeter.samplers.SampleResult#latencyEnd() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UDPSampler.java From jmeter-plugins with Apache License 2.0 | 6 votes |
private ByteArrayOutputStream readResponse(SampleResult res) throws IOException { ByteArrayOutputStream response = new ByteArrayOutputStream(); int cnt; ByteBuffer recvBuf = getRecvBuf(); recvBuf.clear(); if ((cnt = channel.read(recvBuf)) != -1) { res.latencyEnd(); //log.debug("Read " + recvBuf.toString()); recvBuf.flip(); byte[] bytes = new byte[cnt]; recvBuf.get(bytes); response.write(bytes); recvBuf.clear(); } res.latencyEnd(); res.sampleEnd(); res.setBytes(response.size()); return response; }
Example 2
Source File: UDPSampler.java From jmeter-plugins with Apache License 2.0 | 5 votes |
private byte[] noResponseFinish(SampleResult res) throws IOException { res.latencyEnd(); res.sampleEnd(); if (isCloseChannel()) { channel.close(); } return new byte[0]; }
Example 3
Source File: CassandraSampler.java From jmeter-cassandra with Apache License 2.0 | 4 votes |
@Override public SampleResult sample(Entry e) { log.debug("sampling CQL"); SampleResult res = new SampleResult(); res.setSampleLabel(getName()); res.setSamplerData(toString()); res.setDataType(SampleResult.TEXT); res.setContentType("text/plain"); // $NON-NLS-1$ res.setDataEncoding(ENCODING); // Assume we will be successful res.setSuccessful(true); res.setResponseMessageOK(); res.setResponseCodeOK(); res.sampleStart(); Session conn = null; try { if(JOrphanUtils.isBlank(getSessionName())) { throw new IllegalArgumentException("Variable Name must not be null in "+getName()); } try { conn = CassandraConnection.getSession(getSessionName()); } finally { res.latencyEnd(); // use latency to measure connection time } res.setResponseHeaders(conn.toString()); res.setResponseData(execute(conn)); } catch (Exception ex) { res.setResponseMessage(ex.toString()); res.setResponseCode("000"); res.setResponseData(ex.getMessage().getBytes()); res.setSuccessful(false); } // Doesn't apply // finally { // close(conn); // } // TODO: process warnings? Set Code and Message to success? res.sampleEnd(); return res; }
Example 4
Source File: HTTPRawSampler.java From jmeter-plugins with Apache License 2.0 | 4 votes |
protected byte[] readResponse(SocketChannel channel, SampleResult res) throws IOException { ByteArrayOutputStream response = new ByteArrayOutputStream(); ByteBuffer recvBuf = getRecvBuf(); recvBuf.clear(); boolean firstPack = true; int cnt; int responseSize = 0; if (log.isDebugEnabled()) { log.debug("Start reading response"); } try { while ((cnt = channel.read(recvBuf)) != -1) { responseSize += cnt; if (firstPack) { res.latencyEnd(); firstPack = false; } recvBuf.flip(); if (response.size() <= recvDataLimit) { byte[] bytes = new byte[cnt]; recvBuf.get(bytes); response.write(bytes); } recvBuf.clear(); } if (response.size() < 1) { log.warn("Read no bytes from socket, seems it was closed. Let it be so."); channel.close(); } } catch (IOException ex) { channel.close(); throw ex; } if (log.isDebugEnabled()) { log.debug("Done reading response"); } res.sampleEnd(); if (!isUseKeepAlive()) { channel.close(); } res.setBytes(responseSize); return response.toByteArray(); }