1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728
|
/*
This file is part of the KDE project
SPDX-FileCopyrightText: 2004-2014 David Faure <faure@kde.org>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#include <QTest>
#include <QHash>
#include <QList>
#include <QMap>
#include <QVector>
#include <kio/global.h> // filesize_t
#include <kio/udsentry.h>
/*
This is to compare the old list-of-lists API vs a QMap/QHash-based API
in terms of performance.
The number of atoms and their type map to what kio_file would put in
for any normal file.
The lookups are done for two atoms that are present, and for one that is not.
*/
class UdsEntryBenchmark : public QObject
{
Q_OBJECT
public:
UdsEntryBenchmark()
: nameStr(QStringLiteral("name"))
, now(QDateTime::currentDateTime())
, now_time_t(now.toSecsSinceEpoch())
{
}
private Q_SLOTS:
void testKDE3Slave();
void testKDE3App();
void testHashVariantSlave();
void testHashVariantApp();
void testHashStructSlave();
void testHashStructApp();
void testMapStructSlave();
void testMapStructApp();
void testTwoVectorsSlaveFill();
void testTwoVectorsSlaveCompare();
void testTwoVectorsApp();
void testAnotherSlaveFill();
void testAnotherSlaveCompare();
void testAnotherApp();
void testAnotherV2SlaveFill();
void testAnotherV2SlaveCompare();
void testAnotherV2App();
private:
const QString nameStr;
const QDateTime now;
const time_t now_time_t;
};
class OldUDSAtom
{
public:
QString m_str;
long long m_long;
unsigned int m_uds;
};
typedef QList<OldUDSAtom> OldUDSEntry; // well it was a QValueList :)
static void fillOldUDSEntry(OldUDSEntry &entry, time_t now_time_t, const QString &nameStr)
{
OldUDSAtom atom;
atom.m_uds = KIO::UDSEntry::UDS_NAME;
atom.m_str = nameStr;
entry.append(atom);
atom.m_uds = KIO::UDSEntry::UDS_SIZE;
atom.m_long = 123456ULL;
entry.append(atom);
atom.m_uds = KIO::UDSEntry::UDS_MODIFICATION_TIME;
atom.m_long = now_time_t;
entry.append(atom);
atom.m_uds = KIO::UDSEntry::UDS_ACCESS_TIME;
atom.m_long = now_time_t;
entry.append(atom);
atom.m_uds = KIO::UDSEntry::UDS_FILE_TYPE;
atom.m_long = S_IFREG;
entry.append(atom);
atom.m_uds = KIO::UDSEntry::UDS_ACCESS;
atom.m_long = 0644;
entry.append(atom);
atom.m_uds = KIO::UDSEntry::UDS_USER;
atom.m_str = nameStr;
entry.append(atom);
atom.m_uds = KIO::UDSEntry::UDS_GROUP;
atom.m_str = nameStr;
entry.append(atom);
}
void UdsEntryBenchmark::testKDE3Slave()
{
QBENCHMARK {
OldUDSEntry entry;
fillOldUDSEntry(entry, now_time_t, nameStr);
QCOMPARE(entry.count(), 8);
}
}
void UdsEntryBenchmark::testKDE3App()
{
OldUDSEntry entry;
fillOldUDSEntry(entry, now_time_t, nameStr);
QString displayName;
KIO::filesize_t size;
QString url;
QBENCHMARK {
OldUDSEntry::ConstIterator it2 = entry.constBegin();
for (; it2 != entry.constEnd(); it2++) {
switch ((*it2).m_uds) {
case KIO::UDSEntry::UDS_NAME:
displayName = (*it2).m_str;
break;
case KIO::UDSEntry::UDS_URL:
url = (*it2).m_str;
break;
case KIO::UDSEntry::UDS_SIZE:
size = (*it2).m_long;
break;
}
}
QCOMPARE(size, 123456ULL);
QCOMPARE(displayName, QStringLiteral("name"));
QVERIFY(url.isEmpty());
}
}
// QHash or QMap? doesn't seem to make much difference.
typedef QHash<uint, QVariant> UDSEntryHV;
// This uses QDateTime instead of time_t
static void fillUDSEntryHV(UDSEntryHV &entry, const QDateTime &now, const QString &nameStr)
{
entry.reserve(8);
entry.insert(KIO::UDSEntry::UDS_NAME, nameStr);
// we might need a method to make sure people use unsigned long long
entry.insert(KIO::UDSEntry::UDS_SIZE, 123456ULL);
entry.insert(KIO::UDSEntry::UDS_MODIFICATION_TIME, now);
entry.insert(KIO::UDSEntry::UDS_ACCESS_TIME, now);
entry.insert(KIO::UDSEntry::UDS_FILE_TYPE, S_IFREG);
entry.insert(KIO::UDSEntry::UDS_ACCESS, 0644);
entry.insert(KIO::UDSEntry::UDS_USER, nameStr);
entry.insert(KIO::UDSEntry::UDS_GROUP, nameStr);
}
void UdsEntryBenchmark::testHashVariantSlave()
{
const QDateTime now = QDateTime::currentDateTime();
QBENCHMARK {
UDSEntryHV entry;
fillUDSEntryHV(entry, now, nameStr);
QCOMPARE(entry.count(), 8);
}
}
void UdsEntryBenchmark::testHashVariantApp()
{
// Normally the code would look like this, but let's change it to time it like the old api
/*
QString displayName = entry.value( KIO::UDSEntry::UDS_NAME ).toString();
QUrl url = entry.value( KIO::UDSEntry::UDS_URL ).toString();
KIO::filesize_t size = entry.value( KIO::UDSEntry::UDS_SIZE ).toULongLong();
*/
UDSEntryHV entry;
fillUDSEntryHV(entry, now, nameStr);
QString displayName;
KIO::filesize_t size;
QString url;
QBENCHMARK {
// For a field that we assume to always be there
displayName = entry.value(KIO::UDSEntry::UDS_NAME).toString();
// For a field that might not be there
auto it = entry.constFind(KIO::UDSEntry::UDS_URL);
const auto end = entry.cend();
if (it != end) {
url = it.value().toString();
}
it = entry.constFind(KIO::UDSEntry::UDS_SIZE);
if (it != end) {
size = it.value().toULongLong();
}
QCOMPARE(size, 123456ULL);
QCOMPARE(displayName, QStringLiteral("name"));
QVERIFY(url.isEmpty());
}
}
// The KDE4 solution: QHash+struct
// Which one is used depends on UDS_STRING vs UDS_LONG
struct UDSAtom4 { // can't be a union due to qstring...
UDSAtom4()
{
} // for QHash or QMap
UDSAtom4(const QString &s)
: m_str(s)
{
}
UDSAtom4(long long l)
: m_long(l)
{
}
QString m_str;
long long m_long;
};
// Another possibility, to save on QVariant costs
typedef QHash<uint, UDSAtom4> UDSEntryHS; // hash+struct
static void fillQHashStructEntry(UDSEntryHS &entry, time_t now_time_t, const QString &nameStr)
{
entry.reserve(8);
entry.insert(KIO::UDSEntry::UDS_NAME, nameStr);
entry.insert(KIO::UDSEntry::UDS_SIZE, 123456ULL);
entry.insert(KIO::UDSEntry::UDS_MODIFICATION_TIME, now_time_t);
entry.insert(KIO::UDSEntry::UDS_ACCESS_TIME, now_time_t);
entry.insert(KIO::UDSEntry::UDS_FILE_TYPE, S_IFREG);
entry.insert(KIO::UDSEntry::UDS_ACCESS, 0644);
entry.insert(KIO::UDSEntry::UDS_USER, nameStr);
entry.insert(KIO::UDSEntry::UDS_GROUP, nameStr);
}
void UdsEntryBenchmark::testHashStructSlave()
{
QBENCHMARK {
UDSEntryHS entry;
fillQHashStructEntry(entry, now_time_t, nameStr);
QCOMPARE(entry.count(), 8);
}
}
void UdsEntryBenchmark::testHashStructApp()
{
UDSEntryHS entry;
fillQHashStructEntry(entry, now_time_t, nameStr);
QString displayName;
KIO::filesize_t size;
QString url;
QBENCHMARK {
// For a field that we assume to always be there
displayName = entry.value(KIO::UDSEntry::UDS_NAME).m_str;
// For a field that might not be there
auto it = entry.constFind(KIO::UDSEntry::UDS_URL);
const auto end = entry.cend();
if (it != end) {
url = it.value().m_str;
}
it = entry.constFind(KIO::UDSEntry::UDS_SIZE);
if (it != end) {
size = it.value().m_long;
}
QCOMPARE(size, 123456ULL);
QCOMPARE(displayName, QStringLiteral("name"));
QVERIFY(url.isEmpty());
}
}
// Let's see if QMap makes any difference
typedef QMap<uint, UDSAtom4> UDSEntryMS; // map+struct
static void fillQMapStructEntry(UDSEntryMS &entry, time_t now_time_t, const QString &nameStr)
{
entry.insert(KIO::UDSEntry::UDS_NAME, nameStr);
entry.insert(KIO::UDSEntry::UDS_SIZE, 123456ULL);
entry.insert(KIO::UDSEntry::UDS_MODIFICATION_TIME, now_time_t);
entry.insert(KIO::UDSEntry::UDS_ACCESS_TIME, now_time_t);
entry.insert(KIO::UDSEntry::UDS_FILE_TYPE, S_IFREG);
entry.insert(KIO::UDSEntry::UDS_ACCESS, 0644);
entry.insert(KIO::UDSEntry::UDS_USER, nameStr);
entry.insert(KIO::UDSEntry::UDS_GROUP, nameStr);
}
void UdsEntryBenchmark::testMapStructSlave()
{
QBENCHMARK {
UDSEntryMS entry;
fillQMapStructEntry(entry, now_time_t, nameStr);
QCOMPARE(entry.count(), 8);
}
}
void UdsEntryBenchmark::testMapStructApp()
{
UDSEntryMS entry;
fillQMapStructEntry(entry, now_time_t, nameStr);
QString displayName;
KIO::filesize_t size;
QString url;
QBENCHMARK {
// For a field that we assume to always be there
displayName = entry.value(KIO::UDSEntry::UDS_NAME).m_str;
// For a field that might not be there
auto it = entry.constFind(KIO::UDSEntry::UDS_URL);
const auto end = entry.cend();
if (it != end) {
url = it.value().m_str;
}
it = entry.constFind(KIO::UDSEntry::UDS_SIZE);
if (it != end) {
size = it.value().m_long;
}
QCOMPARE(size, 123456ULL);
QCOMPARE(displayName, QStringLiteral("name"));
QVERIFY(url.isEmpty());
}
}
// Frank's suggestion in https://git.reviewboard.kde.org/r/118452/
class FrankUDSEntry
{
public:
class Field
{
public:
inline Field(const QString &value)
: m_str(value)
, m_long(0)
{
}
inline Field(long long value = 0)
: m_long(value)
{
}
QString m_str;
long long m_long;
};
QVector<Field> fields;
// If udsIndexes[i] == uds, then fields[i] contains the value for 'uds'.
QVector<uint> udsIndexes;
void reserve(int size)
{
fields.reserve(size);
udsIndexes.reserve(size);
}
void insert(uint udsField, const QString &value)
{
const int index = udsIndexes.indexOf(udsField);
if (index >= 0) {
fields[index] = Field(value);
} else {
udsIndexes.append(udsField);
fields.append(Field(value));
}
}
void replaceOrInsert(uint udsField, const QString &value)
{
insert(udsField, value);
}
void insert(uint udsField, long long value)
{
const int index = udsIndexes.indexOf(udsField);
if (index >= 0) {
fields[index] = Field(value);
} else {
udsIndexes.append(udsField);
fields.append(Field(value));
}
}
void replaceOrInsert(uint udsField, long long value)
{
insert(udsField, value);
}
int count() const
{
return udsIndexes.count();
}
QString stringValue(uint udsField) const
{
const int index = udsIndexes.indexOf(udsField);
if (index >= 0) {
return fields.at(index).m_str;
} else {
return QString();
}
}
long long numberValue(uint udsField, long long defaultValue = -1) const
{
const int index = udsIndexes.indexOf(udsField);
if (index >= 0) {
return fields.at(index).m_long;
} else {
return defaultValue;
}
}
};
template<class T>
static void fillUDSEntries(T &entry, time_t now_time_t, const QString &nameStr)
{
entry.reserve(8);
// In random order of index
entry.insert(KIO::UDSEntry::UDS_ACCESS_TIME, now_time_t);
entry.insert(KIO::UDSEntry::UDS_MODIFICATION_TIME, now_time_t);
entry.insert(KIO::UDSEntry::UDS_SIZE, 123456ULL);
entry.insert(KIO::UDSEntry::UDS_NAME, nameStr);
entry.insert(KIO::UDSEntry::UDS_GROUP, nameStr);
entry.insert(KIO::UDSEntry::UDS_USER, nameStr);
entry.insert(KIO::UDSEntry::UDS_ACCESS, 0644);
entry.insert(KIO::UDSEntry::UDS_FILE_TYPE, S_IFREG);
}
template<class T>
void testFill(time_t now_time_t, const QString &nameStr)
{
QBENCHMARK {
T entry;
fillUDSEntries<T>(entry, now_time_t, nameStr);
QCOMPARE(entry.count(), 8);
}
}
template<class T>
void testCompare(time_t now_time_t, const QString &nameStr)
{
T entry;
T entry2;
fillUDSEntries<T>(entry, now_time_t, nameStr);
fillUDSEntries<T>(entry2, now_time_t, nameStr);
QCOMPARE(entry.count(), 8);
QCOMPARE(entry2.count(), 8);
QBENCHMARK {
bool equal = entry.stringValue(KIO::UDSEntry::UDS_NAME) == entry2.stringValue(KIO::UDSEntry::UDS_NAME)
&& entry.numberValue(KIO::UDSEntry::UDS_SIZE) == entry2.numberValue(KIO::UDSEntry::UDS_SIZE)
&& entry.numberValue(KIO::UDSEntry::UDS_MODIFICATION_TIME) == entry2.numberValue(KIO::UDSEntry::UDS_MODIFICATION_TIME)
&& entry.numberValue(KIO::UDSEntry::UDS_ACCESS_TIME) == entry2.numberValue(KIO::UDSEntry::UDS_ACCESS_TIME)
&& entry.numberValue(KIO::UDSEntry::UDS_FILE_TYPE) == entry2.numberValue(KIO::UDSEntry::UDS_FILE_TYPE)
&& entry.numberValue(KIO::UDSEntry::UDS_ACCESS) == entry2.numberValue(KIO::UDSEntry::UDS_ACCESS)
&& entry.stringValue(KIO::UDSEntry::UDS_USER) == entry2.stringValue(KIO::UDSEntry::UDS_USER)
&& entry.stringValue(KIO::UDSEntry::UDS_GROUP) == entry2.stringValue(KIO::UDSEntry::UDS_GROUP);
QVERIFY(equal);
}
}
template<class T>
void testApp(time_t now_time_t, const QString &nameStr)
{
T entry;
fillUDSEntries<T>(entry, now_time_t, nameStr);
QString displayName;
KIO::filesize_t size;
QString url;
QBENCHMARK {
displayName = entry.stringValue(KIO::UDSEntry::UDS_NAME);
url = entry.stringValue(KIO::UDSEntry::UDS_URL);
size = entry.numberValue(KIO::UDSEntry::UDS_SIZE);
QCOMPARE(size, 123456ULL);
QCOMPARE(displayName, QStringLiteral("name"));
QVERIFY(url.isEmpty());
}
}
void UdsEntryBenchmark::testTwoVectorsSlaveFill()
{
testFill<FrankUDSEntry>(now_time_t, nameStr);
}
void UdsEntryBenchmark::testTwoVectorsSlaveCompare()
{
testCompare<FrankUDSEntry>(now_time_t, nameStr);
}
void UdsEntryBenchmark::testTwoVectorsApp()
{
testApp<FrankUDSEntry>(now_time_t, nameStr);
}
// Instead of two vectors, use only one
class AnotherUDSEntry
{
private:
struct Field {
inline Field()
{
}
inline Field(const uint index, const QString &value)
: m_str(value)
, m_index(index)
{
}
inline Field(const uint index, long long value = 0)
: m_long(value)
, m_index(index)
{
}
// This operator helps to gain 1ms just comparing the key
inline bool operator==(const Field &other) const
{
return m_index == other.m_index;
}
QString m_str;
long long m_long = LLONG_MIN;
uint m_index = 0;
};
std::vector<Field> storage;
public:
void reserve(int size)
{
storage.reserve(size);
}
void insert(uint udsField, const QString &value)
{
Q_ASSERT(udsField & KIO::UDSEntry::UDS_STRING);
Q_ASSERT(std::find_if(storage.cbegin(),
storage.cend(),
[udsField](const Field &entry) {
return entry.m_index == udsField;
})
== storage.cend());
storage.emplace_back(udsField, value);
}
void replaceOrInsert(uint udsField, const QString &value)
{
Q_ASSERT(udsField & KIO::UDSEntry::UDS_STRING);
auto it = std::find_if(storage.begin(), storage.end(), [udsField](const Field &entry) {
return entry.m_index == udsField;
});
if (it != storage.end()) {
it->m_str = value;
return;
}
storage.emplace_back(udsField, value);
}
void insert(uint udsField, long long value)
{
Q_ASSERT(udsField & KIO::UDSEntry::UDS_NUMBER);
Q_ASSERT(std::find_if(storage.cbegin(),
storage.cend(),
[udsField](const Field &entry) {
return entry.m_index == udsField;
})
== storage.cend());
storage.emplace_back(udsField, value);
}
void replaceOrInsert(uint udsField, long long value)
{
Q_ASSERT(udsField & KIO::UDSEntry::UDS_NUMBER);
auto it = std::find_if(storage.begin(), storage.end(), [udsField](const Field &entry) {
return entry.m_index == udsField;
});
if (it != storage.end()) {
it->m_long = value;
return;
}
storage.emplace_back(udsField, value);
}
int count() const
{
return storage.size();
}
QString stringValue(uint udsField) const
{
auto it = std::find_if(storage.cbegin(), storage.cend(), [udsField](const Field &entry) {
return entry.m_index == udsField;
});
if (it != storage.cend()) {
return it->m_str;
}
return QString();
}
long long numberValue(uint udsField, long long defaultValue = -1) const
{
auto it = std::find_if(storage.cbegin(), storage.cend(), [udsField](const Field &entry) {
return entry.m_index == udsField;
});
if (it != storage.cend()) {
return it->m_long;
}
return defaultValue;
}
};
Q_DECLARE_TYPEINFO(AnotherUDSEntry, Q_MOVABLE_TYPE);
void UdsEntryBenchmark::testAnotherSlaveFill()
{
testFill<AnotherUDSEntry>(now_time_t, nameStr);
}
void UdsEntryBenchmark::testAnotherSlaveCompare()
{
testCompare<AnotherUDSEntry>(now_time_t, nameStr);
}
void UdsEntryBenchmark::testAnotherApp()
{
testApp<AnotherUDSEntry>(now_time_t, nameStr);
}
// Instead of two vectors, use only one sorted by index and accessed using a binary search.
class AnotherV2UDSEntry
{
private:
struct Field {
inline Field()
{
}
inline Field(const uint index, const QString &value)
: m_str(value)
, m_index(index)
{
}
inline Field(const uint index, long long value = 0)
: m_long(value)
, m_index(index)
{
}
// This operator helps to gain 1ms just comparing the key
inline bool operator==(const Field &other) const
{
return m_index == other.m_index;
}
QString m_str;
long long m_long = LLONG_MIN;
uint m_index = 0;
};
std::vector<Field> storage;
private:
static inline bool less(const Field &other, const uint index)
{
return other.m_index < index;
}
public:
void reserve(int size)
{
storage.reserve(size);
}
void insert(uint udsField, const QString &value)
{
Q_ASSERT(udsField & KIO::UDSEntry::UDS_STRING);
auto it = std::lower_bound(storage.cbegin(), storage.cend(), udsField, less);
Q_ASSERT(it == storage.cend() || it->m_index != udsField);
storage.insert(it, Field(udsField, value));
}
void replaceOrInsert(uint udsField, const QString &value)
{
Q_ASSERT(udsField & KIO::UDSEntry::UDS_STRING);
auto it = std::lower_bound(storage.begin(), storage.end(), udsField, less);
if (it != storage.end() && it->m_index == udsField) {
it->m_str = value;
return;
}
storage.insert(it, Field(udsField, value));
}
void insert(uint udsField, long long value)
{
Q_ASSERT(udsField & KIO::UDSEntry::UDS_NUMBER);
auto it = std::lower_bound(storage.cbegin(), storage.cend(), udsField, less);
Q_ASSERT(it == storage.end() || it->m_index != udsField);
storage.insert(it, Field(udsField, value));
}
void replaceOrInsert(uint udsField, long long value)
{
Q_ASSERT(udsField & KIO::UDSEntry::UDS_NUMBER);
auto it = std::lower_bound(storage.begin(), storage.end(), udsField, less);
if (it != storage.end() && it->m_index == udsField) {
it->m_long = value;
return;
}
storage.insert(it, Field(udsField, value));
}
int count() const
{
return storage.size();
}
QString stringValue(uint udsField) const
{
auto it = std::lower_bound(storage.cbegin(), storage.cend(), udsField, less);
if (it != storage.end() && it->m_index == udsField) {
return it->m_str;
}
return QString();
}
long long numberValue(uint udsField, long long defaultValue = -1) const
{
auto it = std::lower_bound(storage.cbegin(), storage.cend(), udsField, less);
if (it != storage.end() && it->m_index == udsField) {
return it->m_long;
}
return defaultValue;
}
};
Q_DECLARE_TYPEINFO(AnotherV2UDSEntry, Q_MOVABLE_TYPE);
void UdsEntryBenchmark::testAnotherV2SlaveFill()
{
testFill<AnotherV2UDSEntry>(now_time_t, nameStr);
}
void UdsEntryBenchmark::testAnotherV2SlaveCompare()
{
testCompare<AnotherV2UDSEntry>(now_time_t, nameStr);
}
void UdsEntryBenchmark::testAnotherV2App()
{
testApp<AnotherV2UDSEntry>(now_time_t, nameStr);
}
QTEST_MAIN(UdsEntryBenchmark)
#include "udsentry_api_comparison_benchmark.moc"
|