diff options
| author | KunoiSayami <[email protected]> | 2023-06-05 01:56:37 +0800 |
|---|---|---|
| committer | KunoiSayami <[email protected]> | 2023-06-05 01:56:37 +0800 |
| commit | 5f38ca067108eea5a8c334bd8cbe5866300d585c (patch) | |
| tree | 76e477e0030ffb585bd1cc8bf973017dc4b28885 /expt_0604.cpp | |
| parent | 155b3a832c590c55ea3d89dd0783713f1d0f19c1 (diff) | |
feat: Optimize output
Signed-off-by: KunoiSayami <[email protected]>
Diffstat (limited to 'expt_0604.cpp')
| -rw-r--r-- | expt_0604.cpp | 10 |
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"; } |
