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

io.ebeaninternal.server.autotune.service.ProfileOriginQuery Maven / Gradle / Ivy

There is a newer version: 15.6.0
Show newest version
package io.ebeaninternal.server.autotune.service;

import io.ebeaninternal.server.autotune.AutoTuneCollection;

import java.io.Serializable;
import java.util.concurrent.atomic.LongAdder;

/**
 * Used to accumulate query execution statistics for paths relative to the origin query.
 */
public class ProfileOriginQuery implements Serializable {

  private static final long serialVersionUID = -1133958958072778811L;

  private final String path;

  private final LongAdder exeCount = new LongAdder();

  private final LongAdder totalBeanLoaded = new LongAdder();

  private final LongAdder totalMicros = new LongAdder();

  public ProfileOriginQuery(String path) {
    this.path = path;
  }

  public void add(long beansLoaded, long micros) {
    exeCount.increment();
    totalBeanLoaded.add(beansLoaded);
    totalMicros.add(micros);
  }

  public AutoTuneCollection.EntryQuery createEntryQuery(boolean reset) {

    if (reset) {
      return new AutoTuneCollection.EntryQuery(path, exeCount.sumThenReset(), totalBeanLoaded.sumThenReset(), totalMicros.sumThenReset());

    } else {
      return new AutoTuneCollection.EntryQuery(path, exeCount.sum(), totalBeanLoaded.sum(), totalMicros.sum());
    }
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy