5#include "ns3/core-module.h"
30 if (std::fwrite(buffer, 1, size, file) != size)
52 stream.write(buffer, size);
57main(
int argc,
char* argv[])
61 bool doStream =
false;
65 cmd.AddValue(
"n",
"How many times to write (defaults to 100000", n);
66 cmd.AddValue(
"iter",
"How many times to run the test looking for a min (defaults to 50)", iter);
67 cmd.AddValue(
"doStream",
"Run the C++ I/O benchmark otherwise the C I/O ", doStream);
68 cmd.AddValue(
"binmode",
69 "Select binary mode for the C++ I/O benchmark (defaults to true)",
71 cmd.Parse(argc, argv);
74 std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::nanoseconds::max());
90 stream.open(
"streamtest", std::ios_base::binary | std::ios_base::out);
94 stream.open(
"streamtest", std::ios_base::out);
97 auto start = std::chrono::steady_clock::now();
99 auto end = std::chrono::steady_clock::now();
100 auto resultNs = std::chrono::duration_cast<std::chrono::nanoseconds>(end - start);
101 resultNs = std::min(resultNs, minResultNs);
107 std::cout << std::endl;
118 FILE*
file = fopen(
"filetest",
"w");
120 auto start = std::chrono::steady_clock::now();
122 auto end = std::chrono::steady_clock::now();
123 auto resultNs = std::chrono::duration_cast<std::chrono::nanoseconds>(end - start);
124 resultNs = std::min(resultNs, minResultNs);
130 std::cout << std::endl;
133 std::cout << argv[0] <<
": " << minResultNs.count() <<
"ns" << std::endl;
Parse command-line arguments.
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.
void PerfFile(FILE *file, uint32_t n, const char *buffer, uint32_t size)
Check the performance of writing to file.
void PerfStream(std::ostream &stream, uint32_t n, const char *buffer, uint32_t size)
Check the performance of writing to an output stream.
Every class exported by the ns3 library is enclosed in the ns3 namespace.