use of org.apache.jmeter.report.core.CsvSampleWriter in project jmeter by apache.
the class ExternalSampleSorter method sortAndDump.
private File sortAndDump(final List<Sample> samples, final SampleMetadata sampleMetadata) {
long start = 0;
if (LOG.isDebugEnabled()) {
LOG.debug("sortAndDump(): Sorting " + samples.size() + " samples...");
start = System.currentTimeMillis();
}
final List<Sample> sortedSamples = sortSamplesParallel(samples);
if (sortedSamples.size() != samples.size()) {
throw new SampleException("sort failed ! " + sortedSamples.size() + " != " + samples.size());
}
if (LOG.isDebugEnabled()) {
LOG.debug("sortAndDump(): in " + (System.currentTimeMillis() - start) / 1000f + " s. Sorted " + samples.size() + " samples.");
}
File out = getChunkFile();
if (LOG.isDebugEnabled()) {
LOG.debug("sortAndDump(): Dumping chunk " + out);
start = System.currentTimeMillis();
}
try (CsvSampleWriter csvWriter = new CsvSampleWriter(out, sampleMetadata)) {
for (Sample sample : sortedSamples) {
csvWriter.write(sample);
chunkedSampleCount.incrementAndGet();
}
}
if (LOG.isDebugEnabled()) {
LOG.debug("sortAndDump(): in " + (System.currentTimeMillis() - start) / 1000f + " s : Dumped chunk " + out.getAbsolutePath());
}
return out;
}
use of org.apache.jmeter.report.core.CsvSampleWriter in project jmeter by apache.
the class SampleWriterConsumer method startConsuming.
@Override
public void startConsuming() {
if (outputFile == null) {
File wd = getWorkingDirectory();
wd.mkdir();
if (LOG.isInfoEnabled()) {
LOG.info("startConsuming(): No output file set, writing to work directory :" + wd.getAbsolutePath());
}
outputFile = new File(wd, "samples.csv");
}
outputFile.getParentFile().mkdirs();
channelsCount = getConsumedChannelCount();
csvWriters = new CsvSampleWriter[channelsCount];
for (int i = 0; i < channelsCount; i++) {
csvWriters[i] = new CsvSampleWriter(getOutputFile(i), getConsumedMetadata(i));
if (shouldWriteHeader) {
csvWriters[i].writeHeader();
}
}
}
use of org.apache.jmeter.report.core.CsvSampleWriter in project jmeter by apache.
the class ExternalSampleSorter method mergeFiles.
private void mergeFiles(SampleMetadata metadata, File left, File right, File out, boolean writeHeader) {
if (out == null) {
out = getChunkFile();
}
try (CsvSampleWriter csvWriter = new CsvSampleWriter(out, metadata);
CsvSampleReader l = new CsvSampleReader(left, metadata);
CsvSampleReader r = new CsvSampleReader(right, metadata)) {
if (writeHeader) {
csvWriter.writeHeader();
}
while (l.hasNext() || r.hasNext()) {
if (l.hasNext() && r.hasNext()) {
Sample firstLeft = l.peek();
Sample firstRight = r.peek();
if (leftBeforeRight(firstLeft, firstRight)) {
csvWriter.write(firstLeft);
l.readSample();
} else {
csvWriter.write(firstRight);
r.readSample();
}
} else if (l.hasNext()) {
csvWriter.write(l.readSample());
} else if (r.hasNext()) {
csvWriter.write(r.readSample());
}
}
}
}
Aggregations