1
0

benchmarkdialog.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. static const std::vector<mnd::MandelInfo> benches;
  21. public:
  22. inline Benchmarker(mnd::MandelContext& mndContext) :
  23. mndContext{ mnd::initializeContext() }
  24. {
  25. }
  26. static mnd::MandelViewport benchViewport(void);
  27. std::pair<long long, std::chrono::nanoseconds> measureMips(const std::function<Bitmap<float>*()>& bench) const;
  28. double benchmarkResult(mnd::Generator& mg) const;
  29. public slots:
  30. void start(void);
  31. signals:
  32. void update(BenchmarkResult br);
  33. void finished(void);
  34. };
  35. class BenchmarkDialog : public QDialog
  36. {
  37. Q_OBJECT
  38. private:
  39. Ui::BenchmarkDialog ui;
  40. mnd::MandelContext& mndContext;
  41. QThread benchThread;
  42. Benchmarker benchmarker;
  43. public:
  44. explicit BenchmarkDialog(mnd::MandelContext& mndContext, QWidget *parent = nullptr);
  45. signals:
  46. public slots:
  47. void update(BenchmarkResult br);
  48. private slots:
  49. void on_run_clicked();
  50. };
  51. #endif // BENCHMARKDIALOG_H