forked from cppfastio/fast_io
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
73 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#include <fast_io.h> | ||
#include <fast_io_device.h> | ||
#include <fast_io_legacy.h> | ||
#include <fast_io_driver/timer.h> | ||
#include <vector> | ||
|
||
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<std::size_t> 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]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#include <fast_io.h> | ||
#include <fast_io_device.h> | ||
#include <fast_io_driver/timer.h> | ||
#include <vector> | ||
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<std::size_t> 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]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#include <fast_io.h> | ||
#include <fast_io_device.h> | ||
#include <fast_io_driver/timer.h> | ||
#include <vector> | ||
|
||
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<std::size_t> 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); | ||
} | ||
} |