benchmarkdialog.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #ifndef BENCHMARKDIALOG_H
  2. #define BENCHMARKDIALOG_H
  3. #include <QDialog>
  4. #include <functional>
  5. #include "ui_benchmarks.h"
  6. #include <Mandel.h>
  7. #include "Bitmap.h"
  8. #include <QThread>
  9. struct BenchmarkResult
  10. {
  11. std::vector<std::vector<double>> values;
  12. double percentage = 0.0;
  13. };
  14. Q_DECLARE_METATYPE(BenchmarkResult)
  15. class Benchmarker : public QObject
  16. {
  17. Q_OBJECT
  18. private:
  19. mnd::MandelContext mndContext;
  20. public:
  21. inline Benchmarker(mnd::MandelContext& mndContext) :
  22. mndContext{ mnd::initializeContext() }
  23. {
  24. }
  25. mnd::MandelViewport benchViewport(void) const;
  26. double measureMips(const std::function<Bitmap<float>()>& bench) const;
  27. double benchmarkResult(mnd::Generator& mg) const;
  28. public slots:
  29. void start(void);
  30. signals:
  31. void update(BenchmarkResult br);
  32. void finished(void);
  33. };
  34. class BenchmarkDialog : public QDialog
  35. {
  36. Q_OBJECT
  37. private:
  38. Ui::BenchmarkDialog ui;
  39. mnd::MandelContext& mndContext;
  40. QThread benchThread;
  41. Benchmarker benchmarker;
  42. public:
  43. explicit BenchmarkDialog(mnd::MandelContext& mndContext, QWidget *parent = nullptr);
  44. signals:
  45. public slots:
  46. void update(BenchmarkResult br);
  47. private slots:
  48. void on_run_clicked();
  49. };
  50. #endif // BENCHMARKDIALOG_H