atomic_bomb_engine/models/
result.rs1use crate::models::assert_error_stats::AssertErrKey;
2use crate::models::http_error_stats::HttpErrKey;
3use serde::{Deserialize, Serialize};
4use std::collections::HashMap;
5
6#[derive(Debug, Clone, Serialize, Deserialize)]
7pub struct TestResult {
8 pub total_duration: f64,
9 pub success_rate: f64,
10 pub median_response_time: u64,
11 pub response_time_95: u64,
12 pub response_time_99: u64,
13 pub total_requests: i32,
14 pub rps: f64,
15 pub max_response_time: u64,
16 pub min_response_time: u64,
17 pub err_count: i32,
18 pub total_data_kb: f64,
19 pub throughput_per_second_kb: f64,
20 pub http_errors: HashMap<HttpErrKey, u32>,
21 pub timestamp: u128,
22 pub assert_errors: HashMap<(String, String), u32>,
23}
24
25#[derive(Debug, Clone, Serialize, Deserialize)]
26pub struct BatchResult {
27 pub total_duration: f64,
29 pub success_rate: f64,
31 pub error_rate: f64,
33 pub median_response_time: u64,
35 pub response_time_95: u64,
37 pub response_time_99: u64,
39 pub total_requests: u64,
41 pub rps: f64,
43 pub max_response_time: u64,
45 pub min_response_time: u64,
47 pub err_count: i32,
49 pub total_data_kb: f64,
51 pub throughput_per_second_kb: f64,
53 pub http_errors: HashMap<HttpErrKey, u32>,
55 pub timestamp: u128,
57 pub assert_errors: HashMap<AssertErrKey, u32>,
59 pub total_concurrent_number: i32,
61 pub api_results: Vec<ApiResult>,
63 pub errors_per_second: usize,
65}
66
67#[derive(Debug, Clone, Serialize, Deserialize)]
68pub struct ApiResult {
69 pub name: String,
70 pub url: String,
71 pub host: String,
72 pub path: String,
73 pub method: String,
74 pub success_rate: f64,
75 pub error_rate: f64,
76 pub median_response_time: u64,
77 pub response_time_95: u64,
78 pub response_time_99: u64,
79 pub total_requests: u64,
80 pub rps: f64,
81 pub max_response_time: u64,
82 pub min_response_time: u64,
83 pub err_count: i32,
84 pub total_data_kb: f64,
85 pub throughput_per_second_kb: f64,
86 pub concurrent_number: i32,
87}
88
89impl ApiResult {
90 pub fn new() -> Self {
91 Self {
92 name: String::new(),
93 url: String::new(),
94 host: String::new(),
95 path: String::new(),
96 method: String::new(),
97 success_rate: 0.0,
98 error_rate: 0.0,
99 median_response_time: 0,
100 response_time_95: 0,
101 response_time_99: 0,
102 total_requests: 0,
103 rps: 0.0,
104 max_response_time: 0,
105 min_response_time: 0,
106 err_count: 0,
107 total_data_kb: 0.0,
108 throughput_per_second_kb: 0.0,
109 concurrent_number: 0,
110 }
111 }
112}