1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
use std::collections::HashMap;
use serde::{Deserialize, Serialize};

#[derive(Debug)]
#[derive(Clone, Serialize, Deserialize)]
pub struct TestResult {
    pub total_duration: f64,
    pub success_rate: f64,
    pub median_response_time: u64,
    pub response_time_95: u64,
    pub response_time_99: u64,
    pub total_requests: i32,
    pub rps: f64,
    pub max_response_time: u64,
    pub min_response_time: u64,
    pub err_count: i32,
    pub total_data_kb: f64,
    pub throughput_per_second_kb: f64,
    pub http_errors: HashMap<(u16, String, String), u32>,
    pub timestamp: u128,
    pub assert_errors: HashMap<(String, String), u32>
}

#[derive(Debug)]
#[derive(Clone, Serialize, Deserialize)]
pub struct BatchResult {
    pub total_duration: f64,
    pub success_rate: f64,
    pub error_rate: f64,
    pub median_response_time: u64,
    pub response_time_95: u64,
    pub response_time_99: u64,
    pub total_requests: u64,
    pub rps: f64,
    pub max_response_time: u64,
    pub min_response_time: u64,
    pub err_count: i32,
    pub total_data_kb: f64,
    pub throughput_per_second_kb: f64,
    pub http_errors: HashMap<(u16, String, String), u32>,
    pub timestamp: u128,
    pub assert_errors: HashMap<(String, String), u32>,
    pub total_concurrent_number: i32,
    pub api_results: Vec<ApiResult>
}

#[derive(Debug)]
#[derive(Clone, Serialize, Deserialize)]
pub struct ApiResult{
    pub name: String,
    pub url: String,
    pub method: String,
    pub success_rate: f64,
    pub error_rate: f64,
    pub median_response_time: u64,
    pub response_time_95: u64,
    pub response_time_99: u64,
    pub total_requests: u64,
    pub rps: f64,
    pub max_response_time: u64,
    pub min_response_time: u64,
    pub err_count: i32,
    pub total_data_kb: f64,
    pub throughput_per_second_kb: f64,
    pub concurrent_number: i32,
}

impl ApiResult {
    pub fn new() -> Self {
        Self {
            name: String::new(),
            url: String::new(),
            method: String::new(),
            success_rate: 0.0,
            error_rate: 0.0,
            median_response_time: 0,
            response_time_95: 0,
            response_time_99: 0,
            total_requests: 0,
            rps: 0.0,
            max_response_time: 0,
            min_response_time: 0,
            err_count: 0,
            total_data_kb: 0.0,
            throughput_per_second_kb: 0.0,
            concurrent_number: 0,
        }
    }
}