Ejemplo n.º 1
0
  @Test
  public void testLexerPerformance() throws Exception {

    // generate a sample JSON array
    StringBuilder sample = new StringBuilder();
    sample.append("[");
    int i = 0;
    final int N = 5000;
    for (; i < N; i++) {
      sample.append(i);
      sample.append(",");
    }
    sample.append(i);
    sample.append("]");

    String json = sample.toString();

    StopWatch timer = new StopWatch();

    for (int n = 0; n < 500; n++) {
      JSONLexer lexer = new JSONLexer(json);

      Token t;
      while ((t = lexer.nextToken()) != null) {}
    }
    _logger.info("time: " + timer.getElapsedTime());
  }