UNPKG

@oaklean/profiler

Version:

A library to measure the energy consumption of your javascript/typescript code

44 lines (43 loc) 1.7 kB
import { MetricsDataCollection, IPerfSensorInterfaceOptions, NanoSeconds_BigInt, SensorInterfaceType } from '@oaklean/profiler-core'; import { BaseSensorInterface } from '../BaseSensorInterface'; /** * This SensorInterface uses the data provided by the perf command line tool. * This Provider can only be used on Linux with Perf installed and a CPU that supports RAPL * * Man Page to perf: * https://linux.die.net/man/1/perf */ export declare enum PerfEvent { ENERGY_CORES = "power/energy-cores/", ENERGY_RAM = "power/energy-ram/" } export type MeasurementTypeAvailable = { [PerfEvent.ENERGY_CORES]: boolean; [PerfEvent.ENERGY_RAM]: boolean; }; export declare class PerfSensorInterface extends BaseSensorInterface { private _executable; private _options; private _childProcess; private _startTime; private _stopTime; private _availableMeasurementTypes; private cleanExit; constructor(options: IPerfSensorInterfaceOptions, debugOptions?: { startTime: NanoSeconds_BigInt; stopTime: NanoSeconds_BigInt; }); type(): SensorInterfaceType; commandLineArgs(): Promise<string[]>; canBeExecuted(): Promise<boolean>; availableMeasurementTypes(): Promise<MeasurementTypeAvailable>; checkEventAvailability(eventName: string): Promise<boolean>; isRunning(): boolean; static runningInstances(): string[]; getOutputContent(): string | undefined; readSensorValues(pid: number): Promise<MetricsDataCollection | undefined>; get startTime(): NanoSeconds_BigInt | undefined; get stopTime(): NanoSeconds_BigInt | undefined; startProfiling(): Promise<void>; stopProfiling(): Promise<void>; }