// Benchmark definitions for code generator
// Each benchmark automatically gets divan + gungraun versions for all 5 targets

benchmark name="simple_struct" type="SimpleRecord" category="micro" {
    json "{\"id\": 42, \"name\": \"test\", \"active\": true}"
}

benchmark name="single_nested_struct" type="Outer" category="micro" {
    json "{\"id\": 42, \"inner\": {\"x\": 10, \"y\": 20}, \"name\": \"test\"}"
}

benchmark name="simple_with_options" type="WithOptions" category="micro" {
    json "{\"id\": 42, \"maybe_count\": 123, \"maybe_flag\": null, \"maybe_value\": 2.5}"
}

// Type definitions
type_def name="SimpleRecord" {
    code """
#[derive(Debug, PartialEq, Facet, serde::Serialize, serde::Deserialize, Clone)]
struct SimpleRecord {
    id: u64,
    name: String,
    active: bool,
}
"""
}

type_def name="Inner" {
    code """
#[derive(Debug, PartialEq, Facet, serde::Serialize, serde::Deserialize, Clone)]
struct Inner {
    x: i64,
    y: i64,
}
"""
}

type_def name="Outer" {
    code """
#[derive(Debug, PartialEq, Facet, serde::Serialize, serde::Deserialize, Clone)]
struct Outer {
    id: u64,
    inner: Inner,
    name: String,
}
"""
}

type_def name="WithOptions" {
    code """
#[derive(Debug, PartialEq, Facet, serde::Serialize, serde::Deserialize, Clone)]
struct WithOptions {
    id: u64,
    maybe_count: Option<i64>,
    maybe_flag: Option<bool>,
    maybe_value: Option<f64>,
}
"""
}

// ============================================================================
// Synthetic Benchmarks (Generated Data)
// ============================================================================

benchmark name="booleans" type="Vec<bool>" category="synthetic" {
    generated "booleans"
}

benchmark name="integers" type="Vec<u64>" category="synthetic" {
    generated "integers"
}

benchmark name="floats" type="Vec<f64>" category="synthetic" {
    generated "floats"
}

benchmark name="short_strings" type="Vec<String>" category="synthetic" {
    generated "short_strings"
}

benchmark name="long_strings" type="Vec<String>" category="synthetic" {
    generated "long_strings"
}

benchmark name="escaped_strings" type="Vec<String>" category="synthetic" {
    generated "escaped_strings"
}

benchmark name="hashmaps" type="std::collections::HashMap<String, u64>" category="synthetic" {
    generated "hashmaps"
}

benchmark name="nested_structs" type="Vec<NestedOuter>" category="synthetic" {
    generated "nested_structs"
}

benchmark name="options" type="Vec<OptionsMaybeData>" category="synthetic" {
    generated "options"
}

type_def name="NestedOuter" {
    code """
#[derive(Debug, PartialEq, Facet, serde::Serialize, serde::Deserialize, Clone)]
struct NestedOuter {
    id: u64,
    inner: NestedInner,
}
"""
}

type_def name="NestedInner" {
    code """
#[derive(Debug, PartialEq, Facet, serde::Serialize, serde::Deserialize, Clone)]
struct NestedInner {
    name: String,
    value: f64,
    deep: NestedDeep,
}
"""
}

type_def name="NestedDeep" {
    code """
#[derive(Debug, PartialEq, Facet, serde::Serialize, serde::Deserialize, Clone)]
struct NestedDeep {
    flag: bool,
    count: u32,
}
"""
}

type_def name="OptionsMaybeData" {
    code """
#[derive(Debug, PartialEq, Facet, serde::Serialize, serde::Deserialize, Clone)]
struct OptionsMaybeData {
    required: u64,
    optional_string: Option<String>,
    optional_number: Option<f64>,
}
"""
}

// ============================================================================
// Realistic Benchmarks (Large Real-World Data)
// ============================================================================

benchmark name="twitter" type="TwitterResponseSparse" category="realistic" {
    json_brotli "corpus/twitter.json.br"
}

benchmark name="canada" type="Canada" category="realistic" {
    json_brotli "corpus/canada.json.br"
}

// Twitter types
type_def name="TwitterResponseSparse" {
    code """
#[derive(Debug, PartialEq, Facet, serde::Serialize, serde::Deserialize, Clone)]
struct TwitterResponseSparse {
    statuses: Vec<StatusSparse>,
}
"""
}

type_def name="StatusSparse" {
    code """
#[derive(Debug, PartialEq, Facet, serde::Serialize, serde::Deserialize, Clone)]
struct StatusSparse {
    id: u64,
    text: String,
    user: UserSparse,
    retweet_count: u32,
    favorite_count: u32,
}
"""
}

type_def name="UserSparse" {
    code """
#[derive(Debug, PartialEq, Facet, serde::Serialize, serde::Deserialize, Clone)]
struct UserSparse {
    id: u64,
    screen_name: String,
    followers_count: u32,
}
"""
}

// Canada GeoJSON types
type_def name="Canada" {
    code """
#[derive(Debug, PartialEq, Facet, serde::Serialize, serde::Deserialize, Clone)]
struct Canada {
    #[facet(rename = "type")]
    #[serde(rename = "type")]
    type_: String,
    features: Vec<Feature>,
}
"""
}

type_def name="Feature" {
    code """
#[derive(Debug, PartialEq, Facet, serde::Serialize, serde::Deserialize, Clone)]
struct Feature {
    #[facet(rename = "type")]
    #[serde(rename = "type")]
    type_: String,
    properties: Properties,
    geometry: Geometry,
}
"""
}

type_def name="Properties" {
    code """
#[derive(Debug, PartialEq, Facet, serde::Serialize, serde::Deserialize, Clone)]
struct Properties {
    name: String,
}
"""
}

type_def name="Geometry" {
    code """
#[derive(Debug, PartialEq, Facet, serde::Serialize, serde::Deserialize, Clone)]
struct Geometry {
    #[facet(rename = "type")]
    #[serde(rename = "type")]
    type_: String,
    coordinates: Vec<Vec<Vec<f64>>>,
}
"""
}

benchmark name="citm_catalog" type="CitmCatalog" category="realistic" {
    json_brotli "corpus/citm_catalog.json.br"
}

// CITM Catalog types (event ticketing data)
type_def name="CitmCatalog" {
    code """
#[derive(Debug, PartialEq, Facet, serde::Serialize, serde::Deserialize, Clone)]
struct CitmCatalog {
    #[serde(rename = "areaNames")]
    #[facet(rename = "areaNames")]
    area_names: std::collections::HashMap<String, String>,
    #[serde(rename = "audienceSubCategoryNames")]
    #[facet(rename = "audienceSubCategoryNames")]
    audience_sub_category_names: std::collections::HashMap<String, String>,
    #[serde(rename = "blockNames")]
    #[facet(rename = "blockNames")]
    block_names: std::collections::HashMap<String, String>,
    events: std::collections::HashMap<String, Event>,
    performances: Vec<Performance>,
    #[serde(rename = "seatCategoryNames")]
    #[facet(rename = "seatCategoryNames")]
    seat_category_names: std::collections::HashMap<String, String>,
    #[serde(rename = "subTopicNames")]
    #[facet(rename = "subTopicNames")]
    sub_topic_names: std::collections::HashMap<String, String>,
    #[serde(rename = "subjectNames")]
    #[facet(rename = "subjectNames")]
    subject_names: std::collections::HashMap<String, String>,
    #[serde(rename = "topicNames")]
    #[facet(rename = "topicNames")]
    topic_names: std::collections::HashMap<String, String>,
    #[serde(rename = "topicSubTopics")]
    #[facet(rename = "topicSubTopics")]
    topic_sub_topics: std::collections::HashMap<String, Vec<u64>>,
    #[serde(rename = "venueNames")]
    #[facet(rename = "venueNames")]
    venue_names: std::collections::HashMap<String, String>,
}
"""
}

type_def name="Event" {
    code """
#[derive(Debug, PartialEq, Facet, serde::Serialize, serde::Deserialize, Clone)]
struct Event {
    description: Option<String>,
    id: u64,
    logo: Option<String>,
    name: String,
    #[serde(rename = "subTopicIds")]
    #[facet(rename = "subTopicIds")]
    sub_topic_ids: Vec<u64>,
    #[serde(rename = "subjectCode")]
    #[facet(rename = "subjectCode")]
    subject_code: Option<String>,
    subtitle: Option<String>,
    #[serde(rename = "topicIds")]
    #[facet(rename = "topicIds")]
    topic_ids: Vec<u64>,
}
"""
}

type_def name="Performance" {
    code """
#[derive(Debug, PartialEq, Facet, serde::Serialize, serde::Deserialize, Clone)]
struct Performance {
    #[serde(rename = "eventId")]
    #[facet(rename = "eventId")]
    event_id: u64,
    id: u64,
    logo: Option<String>,
    name: Option<String>,
    prices: Vec<Price>,
    #[serde(rename = "seatCategories")]
    #[facet(rename = "seatCategories")]
    seat_categories: Vec<SeatCategory>,
    #[serde(rename = "seatMapImage")]
    #[facet(rename = "seatMapImage")]
    seat_map_image: Option<String>,
    start: u64,
    #[serde(rename = "venueCode")]
    #[facet(rename = "venueCode")]
    venue_code: String,
}
"""
}

type_def name="Price" {
    code """
#[derive(Debug, PartialEq, Facet, serde::Serialize, serde::Deserialize, Clone)]
struct Price {
    amount: u64,
    #[serde(rename = "audienceSubCategoryId")]
    #[facet(rename = "audienceSubCategoryId")]
    audience_sub_category_id: u64,
    #[serde(rename = "seatCategoryId")]
    #[facet(rename = "seatCategoryId")]
    seat_category_id: u64,
}
"""
}

type_def name="SeatCategory" {
    code """
#[derive(Debug, PartialEq, Facet, serde::Serialize, serde::Deserialize, Clone)]
struct SeatCategory {
    areas: Vec<Area>,
    #[serde(rename = "seatCategoryId")]
    #[facet(rename = "seatCategoryId")]
    seat_category_id: u64,
}
"""
}

type_def name="Area" {
    code """
#[derive(Debug, PartialEq, Facet, serde::Serialize, serde::Deserialize, Clone)]
struct Area {
    #[serde(rename = "areaId")]
    #[facet(rename = "areaId")]
    area_id: u64,
    #[serde(rename = "blockIds")]
    #[facet(rename = "blockIds")]
    block_ids: Vec<u64>,
}
"""
}

// ============================================================================
// Flatten Benchmarks (Flattened Enums)
// ============================================================================

benchmark name="flatten_2enums" type="Vec<Config2Enums>" category="synthetic" {
    generated "flatten_2enums"
}

benchmark name="flatten_4enums" type="Vec<Config4Enums>" category="synthetic" {
    generated "flatten_4enums"
}

// Auth method variants
type_def name="AuthPassword" {
    code """
#[derive(Debug, PartialEq, Facet, serde::Serialize, serde::Deserialize, Clone)]
struct AuthPassword {
    password: String,
}
"""
}

type_def name="AuthToken" {
    code """
#[derive(Debug, PartialEq, Facet, serde::Serialize, serde::Deserialize, Clone)]
struct AuthToken {
    token: String,
    token_expiry: u64,
}
"""
}

type_def name="AuthMethod" {
    code """
#[derive(Debug, PartialEq, Facet, serde::Serialize, serde::Deserialize, Clone)]
#[repr(C)]
enum AuthMethod {
    Password(AuthPassword),
    Token(AuthToken),
}
"""
}

// Transport variants
type_def name="TransportTcp" {
    code """
#[derive(Debug, PartialEq, Facet, serde::Serialize, serde::Deserialize, Clone)]
struct TransportTcp {
    tcp_port: u16,
}
"""
}

type_def name="TransportUnix" {
    code """
#[derive(Debug, PartialEq, Facet, serde::Serialize, serde::Deserialize, Clone)]
struct TransportUnix {
    socket_path: String,
}
"""
}

type_def name="Transport" {
    code """
#[derive(Debug, PartialEq, Facet, serde::Serialize, serde::Deserialize, Clone)]
#[repr(C)]
enum Transport {
    Tcp(TransportTcp),
    Unix(TransportUnix),
}
"""
}

// Storage variants
type_def name="StorageLocal" {
    code """
#[derive(Debug, PartialEq, Facet, serde::Serialize, serde::Deserialize, Clone)]
struct StorageLocal {
    local_path: String,
}
"""
}

type_def name="StorageRemote" {
    code """
#[derive(Debug, PartialEq, Facet, serde::Serialize, serde::Deserialize, Clone)]
struct StorageRemote {
    remote_url: String,
}
"""
}

type_def name="Storage" {
    code """
#[derive(Debug, PartialEq, Facet, serde::Serialize, serde::Deserialize, Clone)]
#[repr(C)]
enum Storage {
    Local(StorageLocal),
    Remote(StorageRemote),
}
"""
}

// Logging variants
type_def name="LogFile" {
    code """
#[derive(Debug, PartialEq, Facet, serde::Serialize, serde::Deserialize, Clone)]
struct LogFile {
    log_path: String,
}
"""
}

type_def name="LogStdout" {
    code """
#[derive(Debug, PartialEq, Facet, serde::Serialize, serde::Deserialize, Clone)]
struct LogStdout {
    log_color: bool,
}
"""
}

type_def name="Logging" {
    code """
#[derive(Debug, PartialEq, Facet, serde::Serialize, serde::Deserialize, Clone)]
#[repr(C)]
enum Logging {
    File(LogFile),
    Stdout(LogStdout),
}
"""
}

// 2-enum config (2×2 = 4 configurations)
type_def name="Config2Enums" {
    code """
#[derive(Debug, PartialEq, Facet, serde::Serialize, serde::Deserialize, Clone)]
struct Config2Enums {
    name: String,
    #[facet(flatten)]
    #[serde(flatten)]
    auth: AuthMethod,
    #[facet(flatten)]
    #[serde(flatten)]
    transport: Transport,
}
"""
}

// 4-enum config (2^4 = 16 configurations)
type_def name="Config4Enums" {
    code """
#[derive(Debug, PartialEq, Facet, serde::Serialize, serde::Deserialize, Clone)]
struct Config4Enums {
    name: String,
    #[facet(flatten)]
    #[serde(flatten)]
    auth: AuthMethod,
    #[facet(flatten)]
    #[serde(flatten)]
    transport: Transport,
    #[facet(flatten)]
    #[serde(flatten)]
    storage: Storage,
    #[facet(flatten)]
    #[serde(flatten)]
    logging: Logging,
}
"""
}
