示例#1
0
  public void javaUtilXmlCompressed(List<EventWrapper<LoggingEvent>> loggingEvents) {
    boolean compressed = true;
    Encoder<LoggingEvent> encoder =
        new XmlEncoder<LoggingEvent>(compressed, LoggingEvent.Level.class);
    Decoder<LoggingEvent> decoder = new XmlDecoder<LoggingEvent>(compressed);
    List<byte[]> collectedBytes = new ArrayList<byte[]>(loggingEvents.size());
    long byteCounter = 0;
    startTest();
    for (EventWrapper<LoggingEvent> current : loggingEvents) {
      byte[] bytes = encoder.encode(current.getEvent());
      byteCounter += bytes.length;
      collectedBytes.add(bytes);
    }
    stopTest("javaBeansXmlCompressed", "encode", byteCounter, loggingEvents.size());
    if (logger.isDebugEnabled()) logger.debug("byteCounter: {}", byteCounter);

    long dummy = 0;
    startTest();
    for (byte[] current : collectedBytes) {
      LoggingEvent event = decoder.decode(current);
      dummy += event.hashCode();
    }
    stopTest("javaBeansXmlCompressed", "decode", byteCounter, loggingEvents.size());
    if (logger.isDebugEnabled()) logger.debug("Dummy: {}", dummy);
  }
示例#2
0
  public void protobufUncompressed(List<EventWrapper<LoggingEvent>> loggingEvents) {
    boolean compressed = false;
    Encoder<LoggingEvent> encoder = new LoggingEventProtobufEncoder(compressed);
    Decoder<LoggingEvent> decoder = new LoggingEventProtobufDecoder(compressed);
    List<byte[]> collectedBytes = new ArrayList<byte[]>(loggingEvents.size());
    long byteCounter = 0;
    startTest();
    for (EventWrapper<LoggingEvent> current : loggingEvents) {
      byte[] bytes = encoder.encode(current.getEvent());
      byteCounter += bytes.length;
      collectedBytes.add(bytes);
    }
    stopTest("protobufUncompressed", "encode", byteCounter, loggingEvents.size());
    if (logger.isDebugEnabled()) logger.debug("byteCounter: {}", byteCounter);

    long dummy = 0;
    startTest();
    for (byte[] current : collectedBytes) {
      LoggingEvent event = decoder.decode(current);
      dummy += event.hashCode();
    }
    stopTest("protobufUncompressed", "decode", byteCounter, loggingEvents.size());
    if (logger.isDebugEnabled()) logger.debug("Dummy: {}", dummy);
  }