use crate::utils::types::{RUMWebTemplate, ReportRawResults};
use rumtk_core::base::RUMResult;
use rumtk_core::buffers::buffer_to_string;
use rumtk_core::buffers::*;
use rumtk_core::serde::{RUMDeJson, RUMSerJson};
use rumtk_core::strings::{rumtk_format, RUMString, RUMStringConversions};
use std::convert::{From, TryFrom};
use std::env::consts;
use std::fmt::Debug;
pub type MetaData = (RUMBuffer,RUMBuffer,RUMBuffer);
#[derive(Default, Debug, RUMDeJson, RUMSerJson, RUMWebTemplate)]
#[template(
source = "
<table>
<tbody>
<tr><td><h3>Architecture</h3></td></tr>
<tr>
<td>
<div class='f9'>
<pre>
{{ cpu_info }}
</pre>
</div>
</td>
</tr>
<tr><td><h3>Available Metrics</h3></td></tr>
<tr>
<td>
<div class='f9'>
<pre>
{{ cpu_hw_metrics }}
</pre>
</div>
</td>
</tr>
<tr>
<td>
<div class='f9'>
<pre>
{{ cpu_cache_metrics }}
</pre>
</div>
</td>
</tr>
<tr>
<td>
<details {% if test_file_sizes.len() < 5 %} open {% endif %}>
<summary><strong><u>Test File Sizes in MB </u></strong></summary>
<ul>
{% for s in test_file_sizes.iter() %}
<li>{{s}}</li>
{% endfor %}
</ul>
</td>
</tr>
</tbody>
</table>
<div class='gap-10'></div>
",
ext = "html"
)]
pub struct BenchmarkMeta {
pub cpu_info: RUMString,
pub cpu_hw_metrics: RUMString,
pub cpu_cache_metrics: RUMString,
pub test_file_sizes: Vec<f32>,
}
impl BenchmarkMeta {
pub fn new() -> RUMResult<Self> {
Ok(Self {
cpu_info: RUMString::new(),
cpu_hw_metrics: RUMString::new(),
cpu_cache_metrics: RUMString::new(),
test_file_sizes: vec![],
})
}
}
impl<'a> TryFrom<MetaData> for BenchmarkMeta {
type Error = RUMString;
fn try_from(data: MetaData) -> Result<Self, Self::Error>
{
let (cpu_info, cpu_hw_metrics, cpu_cache_metrics) = data;
Ok(Self {
cpu_info: buffer_to_string(&cpu_info[..])?,
cpu_hw_metrics: buffer_to_string(&cpu_hw_metrics[..])?,
cpu_cache_metrics: buffer_to_string(&cpu_cache_metrics[..])?,
test_file_sizes: vec![],
})
}
}