1
0

choosegenerators.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. #ifndef CHOOSEGENERATORS_H
  2. #define CHOOSEGENERATORS_H
  3. #include "ui_choosegenerators.h"
  4. #include <Mandel.h>
  5. #include "Bitmap.h"
  6. #include <QDialog>
  7. #include <QValidator>
  8. #include <QLineEdit>
  9. #include <QComboBox>
  10. #include <QRunnable>
  11. #include <QThread>
  12. #include <QThreadPool>
  13. #include <memory>
  14. #include <map>
  15. namespace Ui
  16. {
  17. class ChooseGenerators;
  18. }
  19. class Benchmarker : public QObject, public QRunnable
  20. {
  21. Q_OBJECT
  22. private:
  23. mnd::MandelContext& mndContext;
  24. mnd::MandelGenerator& generator;
  25. int row;
  26. float percentage;
  27. static const std::vector<mnd::MandelInfo> benches;
  28. public:
  29. inline Benchmarker(mnd::MandelContext& mndContext, mnd::MandelGenerator& generator, int row, float percentage) :
  30. mndContext{ mndContext },
  31. generator{ generator },
  32. row{ row },
  33. percentage{ percentage }
  34. {
  35. }
  36. virtual ~Benchmarker(void) override;
  37. static mnd::MandelViewport benchViewport(void);
  38. std::pair<long long, std::chrono::nanoseconds> measureMips(const std::function<Bitmap<float>*()>& bench) const;
  39. double benchmarkResult(mnd::MandelGenerator& mg) const;
  40. void run(void) override;
  41. signals:
  42. void finished(int row, float percentage, double mips);
  43. };
  44. class ChooseGenerators : public QDialog
  45. {
  46. Q_OBJECT
  47. private:
  48. Ui::ChooseGenerators* sadfgsdfg;
  49. std::unique_ptr<Ui::ChooseGenerators> ui;
  50. mnd::MandelContext& mndCtxt;
  51. std::map<QString, mnd::MandelGenerator*> generators;
  52. std::vector<std::pair<QLineEdit*, QComboBox*>> tableContent;
  53. std::unique_ptr<QValidator> floatValidator;
  54. //std::unique_ptr<mnd::AdaptiveGenerator> createdGenerator;
  55. std::unique_ptr<mnd::MandelGenerator> chosenGenerator;
  56. std::vector<mnd::MandelGenerator*> actualGenerators;
  57. QThreadPool benchmarker;
  58. public:
  59. ChooseGenerators(mnd::MandelContext& mndCtxt, QWidget* parent = nullptr);
  60. ~ChooseGenerators();
  61. inline mnd::MandelGenerator* getChosenGenerator(void) { return chosenGenerator.get(); }
  62. private:
  63. QComboBox* createComboBox(void);
  64. QLineEdit* createFloatText(void);
  65. public slots:
  66. private slots:
  67. void setBenchmarkResult(int row, float percentage, double mips);
  68. void on_buttonBox_accepted();
  69. void on_run_clicked();
  70. void on_generatorTable_cellDoubleClicked(int row, int column);
  71. void on_compile_clicked();
  72. void on_benchmark_clicked();
  73. };
  74. #endif // CHOOSEGENERATORS_H