package org.simpleflatmapper;

import com.univocity.parsers.common.ParsingContext;
import com.univocity.parsers.common.processor.AbstractRowProcessor;
import com.univocity.parsers.csv.CsvParserSettings;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.infra.Blackhole;
import org.simpleflatmapper.param.CsvParam;

import java.io.IOException;
import java.io.Reader;

@BenchmarkMode(Mode.AverageTime)
public class UnivocityCsvParserBenchmark {

    @Benchmark
    public void parseCsv(Blackhole blackhole, CsvParam csvParam) throws IOException {
        CsvParserSettings settings = new CsvParserSettings();

        //turning off features enabled by default
        settings.setIgnoreLeadingWhitespaces(false);
        settings.setIgnoreTrailingWhitespaces(false);
        settings.setSkipEmptyLines(false);
        settings.setColumnReorderingEnabled(false);
        settings.setReadInputOnSeparateThread(false);

        settings.setRowProcessor(new AbstractRowProcessor() {
            @Override
            public void rowProcessed(String[] row, ParsingContext context) {
                blackhole.consume(row);
            }
        });

        com.univocity.parsers.csv.CsvParser parser = new com.univocity.parsers.csv.CsvParser(settings);
        try(Reader reader = csvParam.getReader()) {
            parser.parse(reader);
        }
    }
}

@@ -468,16 +468,41 @@
 .Reader;
+%0Aimport java.util.Arrays;
 %0A%0A@Bench
@@ -1267,24 +1267,993 @@
        %7D);%0A%0A
+        com.univocity.parsers.csv.CsvParser parser = new com.univocity.parsers.csv.CsvParser(settings);%0A        try(Reader reader = csvParam.getReader()) %7B%0A            parser.parse(reader);%0A        %7D%0A    %7D%0A%0A    public static void main(String%5B%5D args) throws IOException %7B%0A        CsvParam csvParam = new CsvParam();%0A        csvParam.setUp();%0A%0A        CsvParserSettings settings = new CsvParserSettings();%0A%0A        //turning off features enabled by default%0A        settings.setIgnoreLeadingWhitespaces(false);%0A        settings.setIgnoreTrailingWhitespaces(false);%0A        settings.setSkipEmptyLines(false);%0A        settings.setColumnReorderingEnabled(false);%0A        settings.setReadInputOnSeparateThread(false);%0A%0A        settings.setRowProcessor(new AbstractRowProcessor() %7B%0A            @Override%0A            public void rowProcessed(String%5B%5D row, ParsingContext context) %7B%0A                System.out.println(%22row = %22 + Arrays.toString(row));%0A            %7D%0A        %7D);%0A%0A
         com.

improve perf