summaryrefslogtreecommitdiff
path: root/expt_0604.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'expt_0604.cpp')
-rw-r--r--expt_0604.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/expt_0604.cpp b/expt_0604.cpp
index 9217f9e..a1dbf26 100644
--- a/expt_0604.cpp
+++ b/expt_0604.cpp
@@ -1,4 +1,4 @@
-// Experimental content: Test fstream vs stdio
+// Experimental content: Test fstream vs stdio read file
#include <cassert>
#include <chrono>
@@ -17,7 +17,7 @@ void stdio() {
assert(file);
auto read_count = 0L;
for (unsigned long long l;
- read_count < limit && fscanf(file, "%lld ", &l) != EOF;)
+ read_count < limit && fscanf(file, "%llu ", &l) != EOF;)
read_count++;
fclose(file);
}
@@ -36,8 +36,8 @@ auto measure(const char *function_name, void (*test_function)()) {
auto end = std::chrono::high_resolution_clock ::now();
auto duration = end - start;
std::cout << "Function: " << std::fixed << std::setprecision(3)
- << function_name << " " << (double)duration.count() / 1000.0 << "ms"
- << std::endl;
+ << function_name << " " << (double)duration.count() / 1000.0
+ << "ms\n";
return duration.count();
}
@@ -54,5 +54,5 @@ int main(int argc, char const *argv[]) {
}
auto s = measure("stdio", stdio);
auto f = measure("fstream", fstream);
- std::cout << (s > f ? "stdio" : "fstream") << "win";
+ std::cout << (s < f ? "stdio" : "fstream") << " win\n";
}