{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "urn:ledgermath:api:v1:benchmark",
  "title": "LedgerMath data API, version 1: one benchmark's list of Series",
  "description": "v1/benchmarks/<benchmark>.json: the Series of one benchmark, one row per Series, each with the address of its own file. Each row is the Series' row in the list of every Series, v1/series.json, by the same definition of a row, and in files of one update the same, value for value and byte for byte, in the same order; so from the table of contents a reader reaches any Series this file lists in two requests: this file, whose row of the Series gives a summary of each Method's Derivation of it and the address of its file, then that file. The table of contents, a benchmark's list, the list of every Series and a Series' file are each whole, but fetched together they can be of different updates of the files: an update writes them one after another, a cache may hold one of them from before another changed, and an update that stopped part way leaves them so until the next one. Their counts and rows can then differ: one may hold a Series, or count a Run, that another does not. So a reader takes each file as true of its own update; where two of them differ, it fetches them again later, and they agree once both are of one update. Of the benchmark's Series whose rows take at most 16384 bytes written as JSON with no white space, this file lists, in the order of its rows, as many as fit in 250000 bytes, each row counted as those bytes and 6 more; the first that does not fit and every one after it are left out, as is a longer row, and left_out counts them: each is in v1/series.json and has its own file. So neither what one Series' strings hold nor how many Series there are can make this file too large to publish. Every benchmark whose name is 1 to 64 characters, a lower-case letter then lower-case letters, digits and underscores, has this file, always, whether the table of contents names it or not; its address is the table of contents' benchmarks.benchmark_file_url_template with the name in it, the name every row and every Series' file gives. A benchmark named otherwise has no file of its own: its Series are in v1/series.json alone, and the table of contents counts them. Each Method's own words for what its numbers mean are in v1/series.json and in each Series' file. Each row is written on one line of its own. Version 1 only ever gains fields: a field, once in a v1 file, keeps its name, its type and its meaning, and a reader ignores any field it does not know, which is why no object in this schema forbids members it does not list. A change that would break a reader is published as v2, beside v1.",
  "type": "object",
  "required": ["schema", "schema_url", "index", "url", "benchmark", "count", "left_out", "newest_run_started_at", "series"],
  "properties": {
    "schema": { "description": "What this file is, and which version of its shape.", "const": "ledgermath.api.benchmark/1" },
    "schema_url": { "description": "The address of this schema.", "$ref": "#/$defs/url" },
    "index": { "description": "The address of the table of contents, v1/index.json, which gives the address of the list of every Series.", "$ref": "#/$defs/url" },
    "url": { "description": "This file's own address.", "$ref": "#/$defs/url" },
    "benchmark": { "description": "The benchmark's name, as its Runs give it: 1 to 64 characters, a lower-case letter, then lower-case letters, digits and underscores.", "type": "string", "pattern": "^[a-z][a-z0-9_]{0,63}$" },
    "count": { "description": "How many Series are listed.", "type": "integer", "minimum": 0 },
    "left_out": { "description": "How many of the benchmark's Series are not listed: each because its row takes more than 16384 bytes written as JSON with no white space, or did not fit in 250000 bytes. Each is in v1/series.json and has its own file.", "type": "integer", "minimum": 0 },
    "newest_run_started_at": {
      "description": "When the newest Run of the Series listed started; null when none is listed.",
      "anyOf": [{ "$ref": "#/$defs/time" }, { "type": "null" }]
    },
    "series": {
      "description": "One row per Series of the benchmark, in the order instance type, zone ID, params, build: each the Series' row in v1/series.json.",
      "type": "array",
      "items": { "$ref": "#/$defs/row" }
    }
  },
  "$defs": {
    "url": { "description": "An address: an absolute URL starting http:// or https://.", "type": "string", "pattern": "^https?://" },
    "time": { "description": "UTC, to the nanosecond, as the Run records it.", "type": "string", "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(\\.[0-9]+)?Z$" },
    "method_series": {
      "description": "The Method, by name and version: series, version 1.",
      "type": "object",
      "required": ["name", "version"],
      "properties": { "name": { "description": "The Method's name: series.", "const": "series" }, "version": { "description": "The Method's version: 1.", "const": 1 } }
    },
    "method_requests": {
      "description": "The Method, by name and version: requests, version 1.",
      "type": "object",
      "required": ["name", "version"],
      "properties": { "name": { "description": "The Method's name: requests.", "const": "requests" }, "version": { "description": "The Method's version: 1.", "const": 1 } }
    },
    "params": {
      "description": "The parameter set, as each Run was given it (LM_PARAM_*).",
      "type": "object",
      "additionalProperties": { "description": "One parameter's value, under the parameter's name, as each Run was given it.", "anyOf": [{ "type": "string" }, { "type": "number" }, { "type": "boolean" }] }
    },
    "stat_summary": {
      "description": "Percentiles of time per repetition across the Series' counted Runs. Every counted Run has a time per repetition. A counted Run's time per repetition is infinite, past a double's range, when it is the mean of its two middle samples' ns_per_repetition and their sum overflows (both near the top of a double's range; no real clock comes near): JSON cannot hold it, so its point shows null, and it is counted here all the same; a percentile taken from it, or interpolated towards it, is null. The Runs behind them are the Series' counted points, as its month files hold them.",
      "type": "object",
      "required": ["count", "p5", "p50", "p95"],
      "properties": {
        "count": { "description": "Counted Runs.", "type": "integer", "minimum": 1 },
        "p5": { "description": "The 5th percentile of the counted Runs' times per repetition (count of them), in nanoseconds, by linear interpolation between closest ranks (R type 7). Null when it is infinite or undefined: taken from, or interpolated towards, an infinite time per repetition.", "$ref": "#/$defs/number_or_null" },
        "p50": { "description": "The 50th percentile of the counted Runs' times per repetition (count of them), in nanoseconds, by linear interpolation between closest ranks (R type 7). Null when it is infinite or undefined: taken from, or interpolated towards, an infinite time per repetition.", "$ref": "#/$defs/number_or_null" },
        "p95": { "description": "The 95th percentile of the counted Runs' times per repetition (count of them), in nanoseconds, by linear interpolation between closest ranks (R type 7). Null when it is infinite or undefined: taken from, or interpolated towards, an infinite time per repetition.", "$ref": "#/$defs/number_or_null" }
      }
    },
    "bytes_per_second_summary": {
      "description": "Percentiles of bytes per second across the Series' counted Runs that observed a finite bytes per repetition above 0. A Run among them whose bytes per second is infinite, past a double's range (chiefly one whose time per repetition is 0), cannot have it written in JSON: it is counted here all the same, and a percentile taken from it, or interpolated towards it, is null. The Runs behind them are the Series' counted points whose bytes_per_repetition is not null, as its month files hold them.",
      "type": "object",
      "required": ["count", "p5", "p50", "p95"],
      "properties": {
        "count": { "description": "Counted Runs that observed a finite bytes per repetition above 0, a Run with a bytes per second that is not a finite number included.", "type": "integer", "minimum": 1 },
        "p5": { "description": "The 5th percentile of the bytes per second of the counted Runs that observed a finite bytes per repetition above 0 (count of them), by linear interpolation between closest ranks (R type 7). Null when it is infinite or undefined: taken from, or interpolated towards, a bytes per second that is not a finite number.", "$ref": "#/$defs/number_or_null" },
        "p50": { "description": "The 50th percentile of the bytes per second of the counted Runs that observed a finite bytes per repetition above 0 (count of them), by linear interpolation between closest ranks (R type 7). Null when it is infinite or undefined: taken from, or interpolated towards, a bytes per second that is not a finite number.", "$ref": "#/$defs/number_or_null" },
        "p95": { "description": "The 95th percentile of the bytes per second of the counted Runs that observed a finite bytes per repetition above 0 (count of them), by linear interpolation between closest ranks (R type 7). Null when it is infinite or undefined: taken from, or interpolated towards, a bytes per second that is not a finite number.", "$ref": "#/$defs/number_or_null" }
      }
    },
    "request_stats": {
      "description": "One phase over a set of requests, in nanoseconds: the count of requests, the least and greatest time, and each percentile the count supports (null when it does not), with how many requests are ranked at or above each one reported.",
      "type": "object",
      "required": ["count", "min", "max", "p50", "p90", "p95", "p99", "p99.9", "at_or_above"],
      "properties": {
        "count": { "description": "How many requests the figures are of: those of the set that succeeded and had this phase.", "type": "integer", "minimum": 0 },
        "min": { "description": "The least of their times, in nanoseconds, exactly.", "type": "number" },
        "max": { "description": "The greatest of their times, in nanoseconds, exactly.", "type": "number" },
        "p50": { "description": "The 50th percentile of their times, in nanoseconds, read from the summed histogram: within 1/128 of the exact percentile of the same requests. Null when count is under 2, too few to support it.", "$ref": "#/$defs/number_or_null" },
        "p90": { "description": "The 90th percentile of their times, in nanoseconds, read from the summed histogram: within 1/128 of the exact percentile of the same requests. Null when count is under 10, too few to support it.", "$ref": "#/$defs/number_or_null" },
        "p95": { "description": "The 95th percentile of their times, in nanoseconds, read from the summed histogram: within 1/128 of the exact percentile of the same requests. Null when count is under 20, too few to support it.", "$ref": "#/$defs/number_or_null" },
        "p99": { "description": "The 99th percentile of their times, in nanoseconds, read from the summed histogram: within 1/128 of the exact percentile of the same requests. Null when count is under 100, too few to support it.", "$ref": "#/$defs/number_or_null" },
        "p99.9": { "description": "The 99.9th percentile of their times, in nanoseconds, read from the summed histogram: within 1/128 of the exact percentile of the same requests. Null when count is under 1000, too few to support it.", "$ref": "#/$defs/number_or_null" },
        "at_or_above": {
          "description": "For each percentile reported, how many requests are ranked at or above it (ties counted by rank).",
          "type": "object",
          "properties": {
            "p50": { "description": "How many requests are ranked at or above the 50th percentile; absent when it is not reported.", "type": "integer" },
            "p90": { "description": "How many requests are ranked at or above the 90th percentile; absent when it is not reported.", "type": "integer" },
            "p95": { "description": "How many requests are ranked at or above the 95th percentile; absent when it is not reported.", "type": "integer" },
            "p99": { "description": "How many requests are ranked at or above the 99th percentile; absent when it is not reported.", "type": "integer" },
            "p99.9": { "description": "How many requests are ranked at or above the 99.9th percentile; absent when it is not reported.", "type": "integer" }
          }
        }
      }
    },
    "number_or_null": { "description": "A number, or null.", "anyOf": [{ "type": "number" }, { "type": "null" }] },
    "phase_stats": {
      "description": "Each phase's statistics, by phase; a phase no request had is absent (dns, connect and tls over a kept connection).",
      "type": "object",
      "properties": {
        "dns": { "$ref": "#/$defs/request_stats" },
        "connect": { "$ref": "#/$defs/request_stats" },
        "tls": { "$ref": "#/$defs/request_stats" },
        "send": { "$ref": "#/$defs/request_stats" },
        "first_byte": { "$ref": "#/$defs/request_stats" },
        "headers": { "$ref": "#/$defs/request_stats" },
        "body": { "$ref": "#/$defs/request_stats" },
        "total": { "$ref": "#/$defs/request_stats" }
      }
    },
    "row": {
      "description": "One Series.",
      "type": "object",
      "required": ["id", "url", "benchmark", "params", "build", "instance_type", "availability_zone_id", "runs", "oldest_run_started_at", "newest_run_started_at", "derivations"],
      "properties": {
        "id": { "description": "The Series' id: the first 12 hex digits of the sha256 of its key (benchmark, params, build, instance type, zone ID) as canonical JSON.", "type": "string", "pattern": "^[0-9a-f]{12}$" },
        "url": { "description": "The address of the Series' own file, v1/series/<id>.json.", "$ref": "#/$defs/url" },
        "benchmark": { "description": "The benchmark's name, as its Runs give it.", "type": "string" },
        "params": { "$ref": "#/$defs/params" },
        "build": { "description": "The named build of the benchmark (static, dynamic).", "type": "string" },
        "instance_type": { "description": "The EC2 instance type, as the provider names it.", "anyOf": [{ "type": "string" }, { "type": "null" }] },
        "availability_zone_id": { "description": "The Availability Zone ID, as the provider names it.", "anyOf": [{ "type": "string" }, { "type": "null" }] },
        "runs": { "description": "Runs in the Series, counted or not.", "type": "integer", "minimum": 1 },
        "boots": { "description": "How many boots its Runs were made on: the distinct boots its points name, counted or not. A boot is one fresh machine; each point names its boot (boot) and links its summary (boot_summary). Written since layout 2 (the layout of v1/index.json); a row written before it lacks it.", "type": "integer", "minimum": 1 },
        "oldest_run_started_at": { "description": "When its oldest Run started.", "$ref": "#/$defs/time" },
        "newest_run_started_at": { "description": "When its newest Run started: the moment a citation of the Series as it stands names.", "$ref": "#/$defs/time" },
        "derivations": {
          "description": "A summary of each Method's Derivation of the Series, keyed <method name>_v<version>. Method series v1 derives every Series; Method requests v1 only those whose samples are requests, and its key is absent from the others.",
          "type": "object",
          "required": ["series_v1"],
          "properties": {
            "series_v1": {
              "description": "A summary of Method series v1's Derivation of the Series.",
              "type": "object",
              "required": ["method", "counted_runs", "failed_runs", "groups", "percentiles"],
              "properties": {
                "method": { "$ref": "#/$defs/method_series" },
                "counted_runs": { "description": "Runs this Method counts.", "type": "integer", "minimum": 0 },
                "failed_runs": { "description": "Runs it does not count: shown in their month's file with why, in no percentile.", "type": "integer", "minimum": 0 },
                "groups": { "description": "How many groups its split facts make of the Series' Runs.", "type": "integer", "minimum": 1 },
                "percentiles": {
                  "description": "Across every counted Run of the Series, whatever its group. time_per_repetition_ns is null when no Run counts; bytes_per_second is null when no counted Run observed a finite bytes per repetition above 0.",
                  "type": "object",
                  "required": ["time_per_repetition_ns", "bytes_per_second"],
                  "properties": {
                    "time_per_repetition_ns": { "description": "Nanoseconds per repetition: each Run's median over its counted samples.", "anyOf": [{ "$ref": "#/$defs/stat_summary" }, { "type": "null" }] },
                    "bytes_per_second": { "description": "Bytes per second: each Run's bytes per repetition × 10^9 / its time per repetition in nanoseconds.", "anyOf": [{ "$ref": "#/$defs/bytes_per_second_summary" }, { "type": "null" }] }
                  }
                }
              }
            },
            "requests_v1": {
              "description": "A summary of Method requests v1's Derivation of the Series; absent when that Method does not derive it.",
              "type": "object",
              "required": ["method", "counted_runs", "failed_runs", "groups", "pool"],
              "properties": {
                "method": { "$ref": "#/$defs/method_requests" },
                "counted_runs": { "description": "Runs this Method counts (exit 0, or 4 with failed requests).", "type": "integer", "minimum": 0 },
                "failed_runs": { "description": "Runs it does not count: shown in their month's file with why, left out of its request statistics.", "type": "integer", "minimum": 0 },
                "groups": { "description": "How many groups its split facts, Method series v1's, make of the Series' Runs.", "type": "integer", "minimum": 1 },
                "pool": {
                  "description": "Every succeeded request of the Series' counted Runs, pooled: each phase's statistics, read from the summed histogram (the Series' file holds the histograms, and the breakdowns by request fact).",
                  "type": "object",
                  "required": ["runs", "requests", "failed", "phases"],
                  "properties": {
                    "runs": { "description": "Counted Runs.", "type": "integer", "minimum": 0 },
                    "requests": { "description": "Succeeded requests.", "type": "integer", "minimum": 0 },
                    "failed": { "description": "Failed requests, never timed.", "type": "integer", "minimum": 0 },
                    "phases": { "$ref": "#/$defs/phase_stats" }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}
