HistogramLogReader.d.ts 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import Histogram, { BitBucketSize } from "./Histogram";
  2. /**
  3. * A histogram log reader.
  4. * <p>
  5. * Histogram logs are used to capture full fidelity, per-time-interval
  6. * histograms of a recorded value.
  7. * <p>
  8. * For example, a histogram log can be used to capture high fidelity
  9. * reaction-time logs for some measured system or subsystem component.
  10. * Such a log would capture a full reaction time histogram for each
  11. * logged interval, and could be used to later reconstruct a full
  12. * HdrHistogram of the measured reaction time behavior for any arbitrary
  13. * time range within the log, by adding [only] the relevant interval
  14. * histograms.
  15. * <h3>Histogram log format:</h3>
  16. * A histogram log file consists of text lines. Lines beginning with
  17. * the "#" character are optional and treated as comments. Lines
  18. * containing the legend (starting with "Timestamp") are also optional
  19. * and ignored in parsing the histogram log. All other lines must
  20. * be valid interval description lines. Text fields are delimited by
  21. * commas, spaces.
  22. * <p>
  23. * A valid interval description line contains an optional Tag=tagString
  24. * text field, followed by an interval description.
  25. * <p>
  26. * A valid interval description must contain exactly four text fields:
  27. * <ul>
  28. * <li>StartTimestamp: The first field must contain a number parse-able as a Double value,
  29. * representing the start timestamp of the interval in seconds.</li>
  30. * <li>intervalLength: The second field must contain a number parse-able as a Double value,
  31. * representing the length of the interval in seconds.</li>
  32. * <li>Interval_Max: The third field must contain a number parse-able as a Double value,
  33. * which generally represents the maximum value of the interval histogram.</li>
  34. * <li>Interval_Compressed_Histogram: The fourth field must contain a text field
  35. * parse-able as a Base64 text representation of a compressed HdrHistogram.</li>
  36. * </ul>
  37. * The log file may contain an optional indication of a starting time. Starting time
  38. * is indicated using a special comments starting with "#[StartTime: " and followed
  39. * by a number parse-able as a double, representing the start time (in seconds)
  40. * that may be added to timestamps in the file to determine an absolute
  41. * timestamp (e.g. since the epoch) for each interval.
  42. */
  43. declare class HistogramLogReader {
  44. startTimeSec: number;
  45. baseTimeSec: number;
  46. lines: string[];
  47. currentLineIndex: number;
  48. bitBucketSize: BitBucketSize;
  49. useWebAssembly: boolean;
  50. constructor(logContent: string, bitBucketSize?: BitBucketSize, useWebAssembly?: boolean);
  51. /**
  52. * Read the next interval histogram from the log. Returns a Histogram object if
  53. * an interval line was found, or null if not.
  54. * <p>Upon encountering any unexpected format errors in reading the next interval
  55. * from the file, this method will return a null.
  56. * @return a DecodedInterval, or a null if no appropriate interval found
  57. */
  58. nextIntervalHistogram(rangeStartTimeSec?: number, rangeEndTimeSec?: number): Histogram | null;
  59. private parseStartTimeFromLine;
  60. private parseBaseTimeFromLine;
  61. }
  62. export declare const listTags: (content: string) => string[];
  63. export default HistogramLogReader;