{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://sl0ptiminer.com/data/benchmarks.schema.json",
  "title": "Sl0ptiminer benchmark rows",
  "description": "Publisher measurements, user averages and single user reports in one row model. The build refuses the whole file if any row breaks a rule. Each row is one device: one processor or one card.",
  "type": "object",
  "required": [
    "schema",
    "rows"
  ],
  "additionalProperties": false,
  "properties": {
    "schema": {
      "const": "sloptiminer-benchmarks/3"
    },
    "rows": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "id",
          "source",
          "miner",
          "miner_version",
          "build",
          "algorithm",
          "device",
          "hardware",
          "os_family",
          "hashrate",
          "power",
          "method"
        ],
        "additionalProperties": false,
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^[a-z0-9][a-z0-9-]{2,60}$"
          },
          "miner": {
            "const": "Sl0ptiminer"
          },
          "miner_version": {
            "type": "string",
            "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+([a-z0-9.]*)$",
            "description": "Release versions must be published; development versions must not be published."
          },
          "algorithm": {
            "enum": [
              "hoohash"
            ]
          },
          "device": {
            "enum": [
              "cpu",
              "gpu"
            ],
            "description": "cpu: a processor row. gpu: a graphics card row."
          },
          "hardware": {
            "type": "object",
            "required": [
              "model",
              "arch",
              "environment"
            ],
            "additionalProperties": false,
            "properties": {
              "model": {
                "type": "string",
                "minLength": 4,
                "maxLength": 80,
                "description": "One processor's or one card's model name. The table writes '2 x' itself when there are two.",
                "not": {
                  "pattern": "^\\s*[0-9]+\\s*[xX\u00d7]\\s+"
                }
              },
              "cores": {
                "type": "integer",
                "minimum": 1,
                "description": "Physical cores of this one processor."
              },
              "threads": {
                "type": "integer",
                "minimum": 1,
                "description": "Hardware threads of this one processor."
              },
              "sockets": {
                "type": "integer",
                "minimum": 1,
                "description": "Processor rows only: how many processors of this model the machine had. The row is the best single one.",
                "maximum": 8
              },
              "arch": {
                "enum": [
                  "x86_64",
                  "aarch64"
                ]
              },
              "environment": {
                "enum": [
                  "bare-metal",
                  "virtual-machine",
                  "container"
                ],
                "description": "Where the miner ran. A virtual machine or a container can share its hardware with other work and may be limited to part of it."
              },
              "cpu_quota": {
                "type": "number",
                "exclusiveMinimum": 0,
                "description": "Processors the system allowed the miner to use, when it set a limit (for example 23.0 of 24). Absent when there was no limit."
              },
              "count": {
                "type": "integer",
                "minimum": 1,
                "description": "Card rows only: how many cards of this model mined in the machine. The row is the best single card."
              },
              "memory_gb": {
                "type": "number",
                "exclusiveMinimum": 0,
                "description": "Card rows only: memory of one card in GB."
              },
              "power_limit_w": {
                "type": "integer",
                "minimum": 1,
                "description": "Card rows only: the power limit the card ran with, in watts."
              },
              "power_default_w": {
                "type": "integer",
                "minimum": 1,
                "description": "Card rows only: the card's own default power limit, in watts."
              },
              "clocks_changed": {
                "enum": [
                  "yes",
                  "not-detected",
                  "unknown"
                ],
                "description": "Card rows only: whether the card ran with changed clocks. not-detected: none of the settings the miner can read was changed."
              },
              "core_offset_mhz": {
                "type": "integer",
                "description": "Card rows only: the core clock offset the card ran with, in MHz, when the card reports it. 0 is the card's own setting."
              },
              "memory_offset_mhz": {
                "type": "integer",
                "description": "Card rows only: the memory clock offset the card ran with, in MHz, when the card reports it."
              },
              "core_clock_mhz": {
                "type": "integer",
                "minimum": 1,
                "description": "Card rows only: the middle core clock during the measurement, in MHz. In an average, the middle of its reports."
              },
              "memory_clock_mhz": {
                "type": "integer",
                "minimum": 1,
                "description": "Card rows only: the middle memory clock during the measurement, in MHz. In an average, the middle of its reports."
              },
              "chassis": {
                "enum": [
                  "laptop",
                  "desktop",
                  "server",
                  "other"
                ],
                "description": "The kind of machine, when the system reports it. Rows of different kinds are never combined."
              },
              "machine": {
                "type": "string",
                "pattern": "^[a-z0-9][a-z0-9._-]{1,62}$",
                "description": "On a Mac, the model identifier in lower case with a dot for the comma: Mac14,2 is mac14.2."
              },
              "product": {
                "type": "string",
                "minLength": 4,
                "maxLength": 80,
                "description": "On a Mac, the product name of that model identifier, when the device table knows it: MacBook Air (M2, 2022)."
              }
            }
          },
          "threads_used": {
            "type": "integer",
            "minimum": 1,
            "description": "Hashing threads the miner ran on this processor."
          },
          "hashrate": {
            "type": "object",
            "required": [
              "hps",
              "kind",
              "window_s"
            ],
            "additionalProperties": false,
            "properties": {
              "hps": {
                "type": "number",
                "exclusiveMinimum": 0,
                "description": "Middle hashrate in hashes per second, as a plain number, of one device: one processor or one card. When the machine had several, this is the best one."
              },
              "kind": {
                "enum": [
                  "pool-accepted",
                  "local"
                ],
                "description": "pool-accepted: computed from shares the pool accepted for the user, after the developer fee. local: hashes tried on the machine, before the developer fee."
              },
              "window_s": {
                "type": "integer",
                "minimum": 60,
                "description": "Length of the measurement in seconds."
              },
              "low": {
                "type": "number"
              },
              "high": {
                "type": "number"
              }
            },
            "allOf": [
              {
                "if": {
                  "required": [
                    "low"
                  ]
                },
                "then": {
                  "required": [
                    "high"
                  ]
                }
              },
              {
                "if": {
                  "required": [
                    "high"
                  ]
                },
                "then": {
                  "required": [
                    "low"
                  ]
                }
              }
            ]
          },
          "power": {
            "type": [
              "object",
              "null"
            ],
            "description": "null when power was not measured.",
            "required": [
              "watts",
              "measured_at"
            ],
            "additionalProperties": false,
            "properties": {
              "watts": {
                "type": "number",
                "exclusiveMinimum": 0,
                "description": "Average watts over the measurement window for the one device of the row: that processor's package, or that card."
              },
              "measured_at": {
                "enum": [
                  "cpu-package",
                  "gpu-board",
                  "gpu-driver"
                ],
                "description": "Only readings the miner takes by itself. cpu-package: the processor's own reading, processor only (no board, memory, fans or power supply losses). gpu-board: the graphics card's own reading, card only. gpu-driver: the reading the card's driver gives; on some cards it does not cover the whole card."
              }
            }
          },
          "os": {
            "type": "string",
            "minLength": 3,
            "maxLength": 60
          },
          "date": {
            "type": "string",
            "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}$"
          },
          "method": {
            "type": "string",
            "pattern": "^/benchmarks/#[a-z0-9-]+$",
            "description": "Anchor of the method section this row follows."
          },
          "notes": {
            "type": "string",
            "maxLength": 200
          },
          "source": {
            "enum": [
              "measured-by-us",
              "user-average",
              "user-report"
            ]
          },
          "build": {
            "enum": [
              "release",
              "development"
            ]
          },
          "instruction_set": {
            "enum": [
              "scalar",
              "avx2",
              "avx512",
              "neon"
            ]
          },
          "os_family": {
            "enum": [
              "linux",
              "windows",
              "macos"
            ]
          },
          "self_check_passed": {
            "type": "boolean"
          },
          "reports": {
            "type": "object",
            "required": [
              "count",
              "left_out"
            ],
            "additionalProperties": false,
            "properties": {
              "count": {
                "type": "integer",
                "minimum": 5
              },
              "left_out": {
                "type": "integer",
                "minimum": 0
              }
            }
          }
        },
        "allOf": [
          {
            "if": {
              "properties": {
                "source": {
                  "const": "measured-by-us"
                }
              }
            },
            "then": {
              "required": [
                "date"
              ]
            },
            "else": {
              "properties": {
                "date": {
                  "not": {}
                },
                "os": {
                  "not": {}
                }
              }
            }
          },
          {
            "if": {
              "properties": {
                "source": {
                  "const": "user-average"
                }
              }
            },
            "then": {
              "required": [
                "reports"
              ]
            },
            "else": {
              "properties": {
                "reports": {
                  "not": {}
                }
              }
            }
          },
          {
            "if": {
              "properties": {
                "build": {
                  "const": "development"
                }
              }
            },
            "then": {
              "properties": {
                "source": {
                  "const": "measured-by-us"
                },
                "method": {
                  "const": "/benchmarks/#development"
                }
              }
            }
          },
          {
            "if": {
              "properties": {
                "source": {
                  "enum": [
                    "user-average",
                    "user-report"
                  ]
                }
              }
            },
            "then": {
              "properties": {
                "build": {
                  "const": "release"
                },
                "hashrate": {
                  "properties": {
                    "kind": {
                      "const": "local"
                    }
                  }
                },
                "method": {
                  "const": "/benchmarks/#user-reports"
                }
              }
            }
          }
        ]
      }
    }
  }
}
