49 { |
49 { |
50 Q_OBJECT |
50 Q_OBJECT |
51 private slots: |
51 private slots: |
52 void reading_speed_direct(); |
52 void reading_speed_direct(); |
53 void reading_speed_propname(); |
53 void reading_speed_propname(); |
54 void reading_speed_propindex_slow(); |
54 void reading_speed_propindex(); |
55 void reading_speed_propindex_fast(); |
|
56 }; |
55 }; |
57 |
56 |
58 void reading_perf::reading_speed_direct() |
57 void reading_perf::reading_speed_direct() |
59 { |
58 { |
60 QAccelerometer sensor; |
59 QAccelerometer sensor; |
61 QVERIFY(sensor.connect()); |
60 QVERIFY(sensor.connectToBackend()); |
62 QAccelerometerReading *reading = sensor.reading(); |
61 QAccelerometerReading *reading = sensor.reading(); |
63 qreal x; |
62 qreal x; |
64 QBENCHMARK { x = reading->x(); } |
63 QBENCHMARK { x = reading->x(); } |
65 } |
64 } |
66 |
65 |
67 void reading_perf::reading_speed_propname() |
66 void reading_perf::reading_speed_propname() |
68 { |
67 { |
69 QSensor sensor; |
68 QSensor sensor("QAccelerometer"); |
70 sensor.setType("QAccelerometer"); |
69 QVERIFY(sensor.connectToBackend()); |
71 QVERIFY(sensor.connect()); |
|
72 QSensorReading *reading = sensor.reading(); |
70 QSensorReading *reading = sensor.reading(); |
73 qreal x; |
71 qreal x; |
74 QBENCHMARK { x = reading->property("x").value<qreal>(); } |
72 QBENCHMARK { x = reading->property("x").value<qreal>(); } |
75 } |
73 } |
76 |
74 |
77 void reading_perf::reading_speed_propindex_slow() |
75 void reading_perf::reading_speed_propindex() |
78 { |
76 { |
79 QSensor sensor; |
77 QSensor sensor("QAccelerometer"); |
80 sensor.setType("QAccelerometer"); |
78 QVERIFY(sensor.connectToBackend()); |
81 QVERIFY(sensor.connect()); |
|
82 QSensorReading *reading = sensor.reading(); |
|
83 qreal x; |
|
84 QBENCHMARK { x = reading->QSensorReading::value(0).value<qreal>(); } |
|
85 } |
|
86 |
|
87 void reading_perf::reading_speed_propindex_fast() |
|
88 { |
|
89 QSensor sensor; |
|
90 sensor.setType("QAccelerometer"); |
|
91 QVERIFY(sensor.connect()); |
|
92 QSensorReading *reading = sensor.reading(); |
79 QSensorReading *reading = sensor.reading(); |
93 qreal x; |
80 qreal x; |
94 QBENCHMARK { x = reading->value(0).value<qreal>(); } |
81 QBENCHMARK { x = reading->value(0).value<qreal>(); } |
95 } |
82 } |
96 |
83 |