+}
+
+QString ProcessingDialog::time2text(const qint64 &msec) const
+{
+ const qint64 MILLISECONDS_PER_DAY = 86399999; //24x60x60x1000 - 1
+ const QTime time = QTime().addMSecs(qMin(msec, MILLISECONDS_PER_DAY));
+
+ QString a, b;
+
+ if(time.hour() > 0)
+ {
+ a = tr("%n hour(s)", "", time.hour());
+ b = tr("%n minute(s)", "", time.minute());
+ }
+ else if(time.minute() > 0)
+ {
+ a = tr("%n minute(s)", "", time.minute());
+ b = tr("%n second(s)", "", time.second());
+ }
+ else
+ {
+ a = tr("%n second(s)", "", time.second());
+ b = tr("%n millisecond(s)", "", time.msec());
+ }
+
+ return QString("%1, %2").arg(a, b);
+}
+
+////////////////////////////////////////////////////////////
+// HELPER FUNCTIONS
+////////////////////////////////////////////////////////////
+
+static int cores2instances(int cores)
+{
+ //This function is a "cubic spline" with sampling points at:
+ //(1,1); (2,2); (4,4); (8,6); (16,8); (32,11); (64,16)
+ static const double LUT[8][5] =
+ {
+ { 1.0, 0.014353554, -0.043060662, 1.028707108, 0.000000000},
+ { 2.0, -0.028707108, 0.215303309, 0.511979167, 0.344485294},
+ { 4.0, 0.010016468, -0.249379596, 2.370710784, -2.133823529},
+ { 8.0, 0.000282437, -0.015762868, 0.501776961, 2.850000000},
+ {16.0, 0.000033270, -0.003802849, 0.310416667, 3.870588235},
+ {32.0, 0.000006343, -0.001217831, 0.227696078, 4.752941176},
+ {64.0, 0.000000000, 0.000000000, 0.000000000, 16.000000000},
+ {DBL_MAX, 0.0, 0.0, 0.0, 0.0}
+ };
+
+ double x = abs(static_cast<double>(cores)), y = 1.0;
+
+ for(size_t i = 0; i < 7; i++)
+ {
+ if((x >= LUT[i][0]) && (x < LUT[i+1][0]))
+ {
+ y = (((((LUT[i][1] * x) + LUT[i][2]) * x) + LUT[i][3]) * x) + LUT[i][4];
+ break;
+ }
+ }
+
+ return qRound(y);
+}