diff --git a/benchmark/0002.file_io_tsc/1mtime/fstream.cc b/benchmark/0002.file_io_tsc/1mtime/fstream.cc new file mode 100644 index 000000000..d4cc279ec --- /dev/null +++ b/benchmark/0002.file_io_tsc/1mtime/fstream.cc @@ -0,0 +1,28 @@ +#include +#include +#include +#include +#include + +int main() +{ + constexpr std::size_t N(1000000); + { + fast_io::timer t(u8"output"); + fast_io::filebuf_file obf(u8"fstream.txt", fast_io::open_mode::out); + std::ostream fout(obf.fb); + for (std::size_t i{}; i != N; ++i) + { + fout << i; + obf.fb->sputc('\n'); + } + } + std::vector vec(N); + { + fast_io::timer t(u8"input"); + fast_io::filebuf_file ibf(u8"fstream.txt", fast_io::open_mode::in); + std::istream fin(ibf.fb); + for (std::size_t i{}; i != N; ++i) + fin >> vec[i]; + } +} diff --git a/benchmark/0002.file_io_tsc/1mtime/iobuf_file.cc b/benchmark/0002.file_io_tsc/1mtime/iobuf_file.cc new file mode 100644 index 000000000..6fb202eb9 --- /dev/null +++ b/benchmark/0002.file_io_tsc/1mtime/iobuf_file.cc @@ -0,0 +1,23 @@ +#include +#include +#include +#include +using namespace fast_io::io; + +int main() +{ + constexpr std::size_t N(1000000); + { + fast_io::timer t(u8"output"); + fast_io::obuf_file obf("iobuf_file.txt"); + for (std::size_t i{}; i != N; ++i) + println(obf, i); + } + std::vector vec(N); + { + fast_io::timer t(u8"input"); + fast_io::ibuf_file ibf("iobuf_file.txt"); + for (std::size_t i{}; i != N; ++i) + scan(ibf, vec[i]); + } +} diff --git a/benchmark/0002.file_io_tsc/1mtime/stdio.cc b/benchmark/0002.file_io_tsc/1mtime/stdio.cc new file mode 100644 index 000000000..81dfdb971 --- /dev/null +++ b/benchmark/0002.file_io_tsc/1mtime/stdio.cc @@ -0,0 +1,22 @@ +#include +#include +#include +#include + +int main() +{ + constexpr std::size_t N(1000000); + { + fast_io::timer t(u8"output"); + fast_io::c_file obf(u8"stdio.txt", fast_io::open_mode::out); + for (std::size_t i{}; i != N; ++i) + fprintf(obf.fp, "%zu\n", i); + } + std::vector vec(N); + { + fast_io::timer t(u8"input"); + fast_io::c_file ibf(u8"stdio.txt", fast_io::open_mode::in); + for (std::size_t i{}; i != N; ++i) + fscanf(ibf.fp, "%zu", vec.data() + i); + } +} \ No newline at end of file