All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.scalecube.services.benchmarks.codec.jackson.ServiceMessageFullDecodeBenchmarks Maven / Gradle / Ivy

package io.scalecube.services.benchmarks.codec.jackson;

import com.codahale.metrics.Timer;
import io.netty.buffer.ByteBuf;
import io.scalecube.benchmarks.BenchmarksSettings;
import io.scalecube.services.api.ServiceMessage;
import io.scalecube.services.benchmarks.codec.ServiceMessageCodecBenchmarksState;
import io.scalecube.services.codec.ServiceMessageCodec;
import java.util.concurrent.TimeUnit;

public class ServiceMessageFullDecodeBenchmarks {

  /**
   * Main method.
   *
   * @param args - params of main method.
   */
  public static void main(String[] args) {
    BenchmarksSettings settings =
        BenchmarksSettings.from(args).durationUnit(TimeUnit.NANOSECONDS).build();
    new ServiceMessageCodecBenchmarksState.Jackson(settings)
        .runForSync(
            state -> {
              Timer timer = state.timer("timer");
              ServiceMessageCodec messageCodec = state.jacksonMessageCodec();
              Class dataType = state.dataType();

              return i -> {
                Timer.Context timeContext = timer.time();
                ByteBuf dataBuffer = state.dataBuffer().retain();
                ByteBuf headersBuffer = state.headersBuffer().retain();
                ServiceMessage message =
                    ServiceMessageCodec.decodeData(
                        messageCodec.decode(dataBuffer, headersBuffer), dataType);
                timeContext.stop();
                return message;
              };
            });
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy