util/src/main/java/org/cache2k/benchmark/util/WebLogReader.java
public static void main(String[] args) throws IOException {
    LineNumberReader in = new LineNumberReader(new InputStreamReader(System.in));
    DataOutputStream out = new DataOutputStream(new BufferedOutputStream(System.out));
    WebLogReader logReader;
    SortedMap<Long, Tuple> map = new TreeMap<>();
    int sampleKeys = 0; Integer.parseInt(args[0]);
    if (args.length > 0) {
      sampleKeys = Integer.parseInt(args[0]);
    }
    if (sampleKeys > 1) {
      int randomCeiling = sampleKeys;
      Random random = new XoShiRo256StarStarRandom(1802);
      logReader = new WebLogReader(() -> random.nextInt(randomCeiling) != 0);
    } else {
      logReader = new WebLogReader(Thinner.NO_SKIP);
    }
    String line;
    int sequenceCount = 0;
    while ((line = in.readLine()) != null) {
      Tuple t = logReader.parseLine(line);
      if (t == null) { continue; }
      map.put(toUpper(t.time) + sequenceCount++ , t);
    }
    if (args.length > 1) {
      long offset = map.firstKey();
      int startTime = Integer.parseInt(args[1]);
      int endTime = Integer.parseInt(args[2]);
      Map orig = map;
      map = map.tailMap(toUpper(startTime) + offset).headMap(toUpper(endTime) + offset);
      System.err.println("Cut away: " + (orig.size() - map.size()));
    }
    int timeOffset = map.values().stream().findFirst().get().time;
    System.err.println("Time range: " + ((map.lastKey() >> 32) - timeOffset));
    for (Tuple t : map.values()) {
      out.writeInt(t.time - timeOffset);
      out.writeInt(t.key);
    }
    System.err.println("Key count=" + logReader.count + ", request count=" + map.size());
    in.close();
    out.close();
  }
/**
   * Parse access log from standard in returning binary output to standard out
   * On integer parameter may be specified to randomly skip every n-th key from the
   * output, which should create a smaller trace with similar properties.
   */
Parse access log from standard in returning binary output to standard out
On integer parameter may be specified to randomly skip every n-th key from the
output, which should create a smaller trace with similar properties.
Parse access log from standard in returning binary output to standard out On integer parameter may be specified to randomly skip every n - th key from the output which should create a smaller trace with similar properties .
public static void main(String[] args) throws IOException {
    LineNumberReader in = new LineNumberReader(new InputStreamReader(System.in));
    DataOutputStream out = new DataOutputStream(new BufferedOutputStream(System.out));
    WebLogReader logReader;
    SortedMap<Long, Tuple> map = new TreeMap<>();
    int sampleKeys = 0; Integer.parseInt(args[0]);
    if (args.length > 0) {
      sampleKeys = Integer.parseInt(args[0]);
    }
    if (sampleKeys > 1) {
      int randomCeiling = sampleKeys;
      Random random = new XoShiRo256StarStarRandom(1802);
      logReader = new WebLogReader(() -> random.nextInt(randomCeiling) != 0);
    } else {
      logReader = new WebLogReader(Thinner.NO_SKIP);
    }
    String line;
    int sequenceCount = 0;
    while ((line = in.readLine()) != null) {
      Tuple t = logReader.parseLine(line);
      if (t == null) { continue; }
      map.put(toUpper(t.time) + sequenceCount++ , t);
    }
    if (args.length > 1) {
      long offset = map.firstKey();
      int startTime = Integer.parseInt(args[1]);
      int endTime = Integer.parseInt(args[2]);
      Map orig = map;
      map = map.tailMap(toUpper(startTime) + offset).headMap(toUpper(endTime) + offset);
      System.err.println("Cut away: " + (orig.size() - map.size()));
    }
    int timeOffset = map.values().stream().findFirst().get().time;
    System.err.println("Time range: " + ((map.lastKey() >> 32) - timeOffset));
    for (Tuple t : map.values()) {
      out.writeInt(t.time - timeOffset);
      out.writeInt(t.key);
    }
    System.err.println("Key count=" + logReader.count + ", request count=" + map.size());
    in.close();
    out.close();
  }
public static void main ( String [ ] args ) throws IOException { LineNumberReader in = new LineNumberReader ( new InputStreamReader ( System . in ) ) ; DataOutputStream out = new DataOutputStream ( new BufferedOutputStream ( System . out ) ) ; WebLogReader logReader ; SortedMap < Long , Tuple > map = new TreeMap < > ( ) ; int sampleKeys = 0 ; Integer . parseInt ( args [ 0 ] ) ; if ( args . length > 0 ) { sampleKeys = Integer . parseInt ( args [ 0 ] ) ; } if ( sampleKeys > 1 ) { int randomCeiling = sampleKeys ; Random random = new XoShiRo256StarStarRandom ( 1802 ) ; logReader = new WebLogReader ( ( ) -> random . nextInt ( randomCeiling ) != 0 ) ; } else { logReader = new WebLogReader ( Thinner . NO_SKIP ) ; } String line ; int sequenceCount = 0 ; while ( ( line = in . readLine ( ) ) != null ) { Tuple t = logReader . parseLine ( line ) ; if ( t == null ) { continue ; } map . put ( toUpper ( t . time ) + sequenceCount ++ , t ) ; } if ( args . length > 1 ) { long offset = map . firstKey ( ) ; int startTime = Integer . parseInt ( args [ 1 ] ) ; int endTime = Integer . parseInt ( args [ 2 ] ) ; Map orig = map ; map = map . tailMap ( toUpper ( startTime ) + offset ) . headMap ( toUpper ( endTime ) + offset ) ; System . err . println ( "Cut away: " + ( orig . size ( ) - map . size ( ) ) ) ; } int timeOffset = map . values ( ) . stream ( ) . findFirst ( ) . get ( ) . time ; System . err . println ( "Time range: " + ( ( map . lastKey ( ) >> 32 ) - timeOffset ) ) ; for ( Tuple t : map . values ( ) ) { out . writeInt ( t . time - timeOffset ) ; out . writeInt ( t . key ) ; } System . err . println ( "Key count=" + logReader . count + ", request count=" + map . size ( ) ) ; in . close ( ) ; out . close ( ) ; }
Parse access log from standard in returning binary output to standard out
 On integer parameter may be specified to randomly skip every n-th key from the
 output, which should create a smaller trace with similar properties.
Parse access log from standard in returning binary output to standard out On integer parameter may be specified to randomly skip every n - th key from the output which should create a smaller trace with similar properties .