function getCpuUtilization()

in src/html_files/cpu_utilization.ts [100:183]


function getCpuUtilization(elem, run, run_data) {
    var x_time = [];
    var y_user = [];
    var y_nice = [];
    var y_system = [];
    var y_irq = [];
    var y_softirq = [];
    var y_idle = [];
    var y_iowait = [];
    var y_steal = [];

    var data = JSON.parse(run_data);
    data.forEach(function (value, index, arr) {
        x_time.push(value.time.TimeDiff);
        y_user.push(value.values.user);
        y_nice.push(value.values.nice);
        y_system.push(value.values.system);
        y_irq.push(value.values.irq);
        y_softirq.push(value.values.softirq);
        y_idle.push(value.values.idle);
        y_steal.push(value.values.steal);
    });
    var user: Partial<Plotly.PlotData> = {
        name: 'User',
        x: x_time,
        y: y_user,
        type: 'scatter',
    };
    var nice: Partial<Plotly.PlotData> = {
        name: 'Nice',
        x: x_time,
        y: y_nice,
        type: 'scatter',
    };
    var system: Partial<Plotly.PlotData> = {
        name: 'System',
        x: x_time,
        y: y_system,
        type: 'scatter',
    };
    var irq: Partial<Plotly.PlotData> = {
        name: 'IRQ',
        x: x_time,
        y: y_irq,
        type: 'scatter',
    };
    var softirq: Partial<Plotly.PlotData> = {
        name: 'SoftIRQ',
        x: x_time,
        y: y_softirq,
        type: 'scatter',
    };
    var idle: Partial<Plotly.PlotData> = {
        name: 'Idle',
        x: x_time,
        y: y_idle,
        type: 'scatter',
    };
    var iowait: Partial<Plotly.PlotData> = {
        name: 'Iowait',
        x: x_time,
        y: y_iowait,
        type: 'scatter',
    };
    var steal: Partial<Plotly.PlotData> = {
        name: 'Steal',
        x: x_time,
        y: y_steal,
        type: 'scatter',
    };
    var TESTER = elem;
    var layout = {
        title: 'Aggregate CPU Utilization',
        xaxis: {
            title: 'Time (s)',
        },
        yaxis: {
            title: 'CPU Utilization (%)',
            range: [0, 100],
        },
    };
    var data_list = [user, nice, system, irq, softirq, idle, iowait, steal];
    Plotly.newPlot(TESTER, data_list, layout, { frameMargins: 0 });
}