public static void main(String[] args) {
long startTime = System.nanoTime();
long startTime2 = System.currentTimeMillis();
for (int i = -1; ++i
#include
int main() {
// Output the result
auto start_time = std::chrono::high_resolution_clock::now();
std::ios::sync_with_stdio(false);
std::cin.tie(NULL);
const size_t bufferSize = 1024 * 1024 * 100;
char *buffer = new char[bufferSize];
std::cout.rdbuf()->pubsetbuf(buffer, bufferSize);
std::ostringstream oss;
for (int i = -1; ++i elapsed = end_time - start_time;
std::cout
#include
int main() {
// Output the result
auto start_time = std::chrono::high_resolution_clock::now();
std::ios::sync_with_stdio(false);
std::cin.tie(NULL);
const size_t bufferSize = 1024 * 1024 * 100;
char *buffer = new char[bufferSize];
std::cout.rdbuf()->pubsetbuf(buffer, bufferSize);
std::ostringstream oss;
for (int i = -1; ++i elapsed = end_time - start_time;
std::cout << "Time taken to output the result: " << elapsed.count() << " milliseconds\n";
delete[] buffer;
return 0;
}
我把同样的代码 在 linux 跑了一遍
g++ main.cpp -O3
./a.out
Time taken to output the result: 11.9875 milliseconds
。。。