<commit_before>package com.octoperf.metrics.windows.pdh;

import com.google.common.collect.ImmutableSet;
import com.octoperf.metrics.service.api.Gauge;
import com.octoperf.metrics.service.api.GaugeService;
import com.octoperf.metrics.windows.pdh.api.PerfmonQueryService;
import com.octoperf.metrics.windows.pdh.api.WindowsProcessMetrics;
import com.octoperf.metrics.windows.pdh.api.WindowsSystemMetrics;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NonNull;
import lombok.experimental.FieldDefaults;

import java.util.Set;

import static java.lang.String.format;
import static lombok.AccessLevel.PACKAGE;

@AllArgsConstructor(access = PACKAGE)
@FieldDefaults(level = AccessLevel.PRIVATE, makeFinal = true)
public final class PdhProcessMetrics implements WindowsProcessMetrics {
  private static final String PROCESS = "Process(%s)";
  private static final Set<String> FORMATTED_COUNTERS = ImmutableSet.of(
      "% Processor Time",
      "% User Time",
      "% Privileged Time",
      "Elapsed Time"
  );

  @NonNull
  PerfmonQueryService perfmon;
  @NonNull
  GaugeService gauges;
  @NonNull
  @Getter
  String instance;
  @NonNull
  WindowsSystemMetrics system;

  @Override
  public double getPercentProcessorTime() {
    return formatted("% Processor Time") / system.getProcessorCount();
  }

  @Override
  public double getPercentUserTime() {
    return formatted("% User Time") / system.getProcessorCount();
  }

  @Override
  public double getPercentPrivilegedTime() {
    return formatted("% Privileged Time") / system.getProcessorCount();
  }

  @Override
  public double getVirtualBytesPeak() {
    return raw("Virtual Bytes Peak");
  }

  @Override
  public double getVirtualBytes() {
    return raw("Virtual Bytes");
  }

  @Override
  public double getPageFaultsPerSec() {
    return perSecond("Page Faults/sec");
  }

  @Override
  public double getWorkingSetPeak() {
    return raw("Working Set Peak");
  }

  @Override
  public double getWorkingSet() {
    return raw("Working Set");
  }

  @Override<commit_msg>fix percent cpu on process<commit_after>package com.octoperf.metrics.windows.pdh;

import com.google.common.collect.ImmutableSet;
import com.octoperf.metrics.service.api.Gauge;
import com.octoperf.metrics.service.api.GaugeService;
import com.octoperf.metrics.windows.pdh.api.PerfmonQueryService;
import com.octoperf.metrics.windows.pdh.api.WindowsProcessMetrics;
import com.octoperf.metrics.windows.pdh.api.WindowsSystemMetrics;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NonNull;
import lombok.experimental.FieldDefaults;

import java.util.Set;

import static java.lang.String.format;
import static lombok.AccessLevel.PACKAGE;

@AllArgsConstructor(access = PACKAGE)
@FieldDefaults(level = AccessLevel.PRIVATE, makeFinal = true)
public final class PdhProcessMetrics implements WindowsProcessMetrics {
  private static final String PROCESS = "Process(%s)";
  private static final Set<String> FORMATTED_COUNTERS = ImmutableSet.of(
      "% Processor Time",
      "% User Time",
      "% Privileged Time",
      "Elapsed Time"
  );

  @NonNull
  PerfmonQueryService perfmon;
  @NonNull
  GaugeService gauges;
  @NonNull
  @Getter
  String instance;
  @NonNull
  WindowsSystemMetrics system;

  @Override
  public double getPercentProcessorTime() {
    return perSecond("% Processor Time") / (100_000 * system.getProcessorCount());
  }

  @Override
  public double getPercentUserTime() {
    return perSecond("% User Time") / (100_000 * system.getProcessorCount());
  }

  @Override
  public double getPercentPrivilegedTime() {
    return perSecond("% Privileged Time") / (100_000 * system.getProcessorCount());
  }

  @Override
  public double getVirtualBytesPeak() {
    return raw("Virtual Bytes Peak");
  }

  @Override
  public double getVirtualBytes() {
    return raw("Virtual Bytes");
  }

  @Override
  public double getPageFaultsPerSec() {
    return perSecond("Page Faults/sec");
  }

  @Override
  public double getWorkingSetPeak() {
    return raw("Working Set Peak");
  }

  @Override
  public double getWorkingSet() {
    return raw("Working Set");
  }

  @Override
{'fraction_non_alphanumeric': 0.10330087865115174, 'fraction_numerical': 0.004274519116599383, 'mean_word_length': 4.578807947019867, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7155163', 'n_tokens_mistral': 1320, 'n_tokens_neox': 1290, 'n_words': 290}