Newer
Older
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
/**
* Histogram showing distribution of processing times
*/
import { useMemo } from 'react';
import { Box, Typography, Paper, Stack } from '@mui/material';
import { Bar } from 'react-chartjs-2';
import type { HistogramData } from '../../types/simulation';
interface ProcessingTimeHistogramProps {
histogramData: HistogramData;
}
export default function ProcessingTimeHistogram({ histogramData }: ProcessingTimeHistogramProps) {
const chartData = useMemo(() => {
const { bins, frequencies } = histogramData;
// Create labels for bin ranges
const labels = bins.slice(0, -1).map((binStart, i) => {
const binEnd = bins[i + 1];
return `${binStart.toFixed(0)}-${binEnd.toFixed(0)}`;
});
return {
labels,
datasets: [
{
label: 'Fréquence',
data: frequencies,
backgroundColor: 'rgba(156, 39, 176, 0.6)',
borderColor: 'rgb(156, 39, 176)',
borderWidth: 1,
},
],
};
}, [histogramData]);
const options = {
responsive: true,
maintainAspectRatio: false,
plugins: {
legend: {
display: false,
},
title: {
display: true,
text: 'Distribution des temps de traitement',
font: {
size: 16,
weight: 600,
},
},
tooltip: {
callbacks: {
title: (context: any) => {
return `Intervalle: ${context[0].label} unités de temps`;
},
label: (context: any) => {
return `Fréquence: ${context.parsed.y} requêtes`;
},
},
},
},
scales: {
x: {
title: {
display: true,
text: 'Temps de traitement (unités)',
},
ticks: {
maxRotation: 45,
minRotation: 45,
},
},
y: {
title: {
display: true,
text: 'Fréquence',
},
beginAtZero: true,
ticks: {
precision: 0,
},
},
},
};
return (
<Paper elevation={2} sx={{ p: 3 }}>
<Box sx={{ height: 400 }}>
<Bar data={chartData} options={options} />
</Box>
<Stack direction="row" spacing={4} sx={{ mt: 3, justifyContent: 'center' }}>
<Box>
<Typography variant="caption" color="text.secondary">
Min
</Typography>
<Typography variant="body2" fontWeight={600} fontFamily="monospace">
{histogramData.min_value.toFixed(2)}
</Typography>
</Box>
<Box>
<Typography variant="caption" color="text.secondary">
Moyenne
</Typography>
<Typography variant="body2" fontWeight={600} fontFamily="monospace">
{histogramData.mean.toFixed(2)}
</Typography>
</Box>
<Box>
<Typography variant="caption" color="text.secondary">
Écart-type
</Typography>
<Typography variant="body2" fontWeight={600} fontFamily="monospace">
{histogramData.std_dev.toFixed(2)}
</Typography>
</Box>
<Box>
<Typography variant="caption" color="text.secondary">
Max
</Typography>
<Typography variant="body2" fontWeight={600} fontFamily="monospace">
{histogramData.max_value.toFixed(2)}
</Typography>
</Box>
</Stack>
<Typography variant="caption" color="text.secondary" sx={{ mt: 2, display: 'block' }}>
Ce graphique montre la distribution des temps de traitement total pour toutes les requêtes
complétées. La forme devrait refléter la distribution exponentielle caractéristique des systèmes M/M/1.
</Typography>
</Paper>
);
}