#include #include #include #include #include #define EE_FILEIO using namespace std; #include unsigned int msg_length_max = 30000000; int main(int argc, char* argv[]) try { char* endptr = 0; long elements; if (argc > 1) { elements = strtol(argv[1], &endptr, 10); } else { elements = 70000; } set st; set st2; for (int j = 1; j <= elements; ++j) { st.insert(j); } int fd = open("eeout", O_RDWR); if (fd < 0) { cout << "open failed." << "\n"; return 0; } auto_ptr sendbuf(new SendBuffer(8192)); auto_ptr > buf(new ReceiveBuffer(8192)); sendbuf->sock_ = fd; buf->sock_ = fd; timeval before_tv, after_tv; struct timezone tz; Msgs msgs; gettimeofday(&before_tv, &tz); msgs.Send(sendbuf.get(), st); gettimeofday(&after_tv, &tz); if (before_tv.tv_sec != after_tv.tv_sec) { after_tv.tv_usec += 1000000; } long diff = after_tv.tv_usec - before_tv.tv_usec; //cout << "Output took (microseconds) " << diff << endl; // lseek(buf->sock_, 0, SEEK_SET); unsigned int msgLength = 0; PersistentRead(buf->sock_, &msgLength, sizeof(msgLength)); buf->SetMsgLength(msgLength); gettimeofday(&before_tv, &tz); msgs.Receive(buf.get(), st2); gettimeofday(&after_tv, &tz); if (before_tv.tv_sec != after_tv.tv_sec) { after_tv.tv_usec += 1000000; } diff = after_tv.tv_usec - before_tv.tv_usec; cout << "That took (microseconds) " << diff << endl; if (st != st2) { cout << "the two sets are not logically equivalent." << endl; } close(fd); return 1; } catch (failure const & ex) { cout << "failure exception: " << ex.what(); }