File indexing completed on 2024-05-12 05:43:34
0001 /* 0002 Copyright (C) 2015 Volker Krause <vkrause@kde.org> 0003 0004 This program is free software; you can redistribute it and/or modify it 0005 under the terms of the GNU Library General Public License as published by 0006 the Free Software Foundation; either version 2 of the License, or (at your 0007 option) any later version. 0008 0009 This program is distributed in the hope that it will be useful, but WITHOUT 0010 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0011 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public 0012 License for more details. 0013 0014 You should have received a copy of the GNU General Public License 0015 along with this program. If not, see <https://www.gnu.org/licenses/>. 0016 */ 0017 0018 #include "loadbenchmarkview.h" 0019 #include "ui_loadbenchmarkview.h" 0020 0021 #include <checks/ldbenchmark.h> 0022 #include <plotter/gnuplotter.h> 0023 #include <loadbenchmarkmodel/loadbenchmarkmodel.h> 0024 0025 #include <QSortFilterProxyModel> 0026 0027 LoadBenchmarkView::LoadBenchmarkView(QWidget* parent): 0028 QWidget(parent), 0029 ui(new Ui::LoadBenchmarkView), 0030 m_model(new LoadBenchmarkModel(this)) 0031 { 0032 ui->setupUi(this); 0033 ui->runButton->setDefaultAction(ui->actionRunBenchmark); 0034 auto proxy = new QSortFilterProxyModel(this); 0035 proxy->setSourceModel(m_model); 0036 ui->dataView->setModel(proxy); 0037 0038 ui->actionRunBenchmark->setEnabled(Gnuplotter::hasGnuplot()); 0039 connect(ui->actionRunBenchmark, &QAction::triggered, this, &LoadBenchmarkView::runBenchmark); 0040 0041 addActions({ ui->actionRunBenchmark }); 0042 } 0043 0044 LoadBenchmarkView::~LoadBenchmarkView() = default; 0045 0046 void LoadBenchmarkView::setFileSet(ElfFileSet* fileSet) 0047 { 0048 m_fileSet = fileSet; 0049 } 0050 0051 void LoadBenchmarkView::runBenchmark() 0052 { 0053 if (!m_fileSet) 0054 return; 0055 0056 m_benchmark = std::make_shared<LDBenchmark>(); 0057 m_benchmark->measureFileSet(m_fileSet); 0058 0059 Gnuplotter plotter; 0060 plotter.setSize(ui->plotter->size()); 0061 plotter.setTemplate(QStringLiteral(":/ldbenchmark.gnuplot")); 0062 0063 m_benchmark->writeCSV(plotter.workingDir() + "/ldbenchmark.csv"); 0064 ui->plotter->setPlotter(std::move(plotter)); 0065 0066 m_model->setBenchmark(m_benchmark); 0067 }