|
27 | 27 | #include "avro/record.hpp"
|
28 | 28 | #include "flatbuffers/test_generated.h"
|
29 | 29 | #include "yas/record.hpp"
|
| 30 | +#include "zpp/record.hpp" |
30 | 31 |
|
31 | 32 | #include "data.hpp"
|
32 | 33 |
|
@@ -518,6 +519,50 @@ yas_serialization_test(size_t iterations)
|
518 | 519 | }
|
519 | 520 | }
|
520 | 521 |
|
| 522 | +void |
| 523 | +zpp_serialization_test(size_t iterations) |
| 524 | +{ |
| 525 | + using namespace zpp_test; |
| 526 | + |
| 527 | + Record r1, r2; |
| 528 | + |
| 529 | + for (size_t i = 0; i < kIntegers.size(); i++) { |
| 530 | + r1.ids.push_back(kIntegers[i]); |
| 531 | + } |
| 532 | + |
| 533 | + for (size_t i = 0; i < kStringsCount; i++) { |
| 534 | + r1.strings.push_back(kStringValue); |
| 535 | + } |
| 536 | + |
| 537 | + std::string serialized; |
| 538 | + |
| 539 | + to_string(r1, serialized); |
| 540 | + from_string(r2, serialized); |
| 541 | + |
| 542 | + if (r1 != r2) { |
| 543 | + throw std::logic_error("zpp' case: deserialization failed"); |
| 544 | + } |
| 545 | + |
| 546 | + std::vector<unsigned char> data; |
| 547 | + data.reserve(serialized.size()); |
| 548 | + |
| 549 | + std::cout << "zpp: version = " << "v0.1" << std::endl; |
| 550 | + std::cout << "zpp: size = " << serialized.size() << " bytes" << std::endl; |
| 551 | + |
| 552 | + auto start = std::chrono::high_resolution_clock::now(); |
| 553 | + for (size_t i = 0; i < iterations; i++) { |
| 554 | + zpp::serializer::memory_output_archive out(data); |
| 555 | + out(r1); |
| 556 | + |
| 557 | + zpp::serializer::memory_input_archive in(data); |
| 558 | + in(r1); |
| 559 | + } |
| 560 | + auto finish = std::chrono::high_resolution_clock::now(); |
| 561 | + auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(finish - start).count(); |
| 562 | + |
| 563 | + std::cout << "zpp: time = " << duration << " milliseconds" << std::endl << std::endl; |
| 564 | +} |
| 565 | + |
521 | 566 | int
|
522 | 567 | main(int argc, char** argv)
|
523 | 568 | {
|
@@ -598,6 +643,10 @@ main(int argc, char** argv)
|
598 | 643 | if (names.empty() || names.find("yas-compact") != names.end()) {
|
599 | 644 | yas_serialization_test<yas::binary | yas::no_header | yas::compacted>(iterations);
|
600 | 645 | }
|
| 646 | + |
| 647 | + if (names.empty() || names.find("zpp") != names.end()) { |
| 648 | + zpp_serialization_test(iterations); |
| 649 | + } |
601 | 650 | } catch (std::exception& exc) {
|
602 | 651 | std::cerr << "Error: " << exc.what() << std::endl;
|
603 | 652 | return EXIT_FAILURE;
|
|
0 commit comments