123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- #include <iostream>
- #include <stdlib.h>
- #include <sys/time.h>
- #include "spir.hpp"
- using std::cout;
- using std::cerr;
- static inline size_t elapsed_us(const struct timeval *start)
- {
- struct timeval end;
- gettimeofday(&end, NULL);
- return (end.tv_sec-start->tv_sec)*1000000 + end.tv_usec - start->tv_usec;
- }
- int main(int argc, char **argv)
- {
- if (argc < 2 || argc > 4) {
- cerr << "Usage: " << argv[0] << " r [num_threads [num_pirs]]\n";
- cerr << "r = log_2(num_records)\n";
- exit(1);
- }
- uint32_t r, num_threads = 1, num_pirs = 1;
- r = strtoul(argv[1], NULL, 10);
- if (argc > 2) {
- num_threads = strtoul(argv[2], NULL, 10);
- }
- if (argc > 3) {
- num_pirs = strtoul(argv[3], NULL, 10);
- }
- cout << "===== ONE-TIME SETUP =====\n\n";
- struct timeval otsetup_start;
- gettimeofday(&otsetup_start, NULL);
- SPIR::init(num_threads);
- string pub_params;
- SPIR_Client client(r, pub_params);
- printf("%u %u %u %u\n", (unsigned char)pub_params[0], (unsigned
- char)pub_params[1], (unsigned char)pub_params[2],
- (unsigned char)pub_params[3]);
- size_t otsetup_us = elapsed_us(&otsetup_start);
- cout << "OT one-time setup: " << otsetup_us << " µs\n";
- return 0;
- }
|