• R/O
  • SSH

コミット

タグ

よく使われているワード(クリックで追加)

javac++androidlinuxc#objective-cqtwindows誰得cocoapythonphprubygameguibathyscaphec翻訳omegat計画中(planning stage)frameworktwittertestdomvb.netdirectxbtronarduinopreviewerゲームエンジン

Comparing performance of a task queued to an existing thread vs. new thread for each task.


コミットメタ情報

リビジョンbe5c4a1b3527801f637c4b98fee6cb8ed5c6da4e (tree)
日時2017-09-01 03:07:52
作者Eric Hopper <hopper@omni...>
コミッターEric Hopper

ログメッセージ

Make magnitude of numbers more easily compared by setting a width.

変更サマリ

差分

diff -r 409f9b966f30 -r be5c4a1b3527 test_thread.cpp
--- a/test_thread.cpp Fri Jun 02 17:47:40 2017 -0700
+++ b/test_thread.cpp Thu Aug 31 11:07:52 2017 -0700
@@ -5,6 +5,7 @@
55 #include "readerwriterqueue.h"
66 #include <stdexcept>
77 #include <string>
8+#include <iomanip>
89
910 extern void do_something();
1011
@@ -57,21 +58,22 @@
5758 using ::std::async;
5859 using ::std::thread;
5960 using ::std::launch;
61+ using ::std::setw;
6062 int whichtests = 31; // All of them, a bitmask.
6163 if (argc > 1) {
6264 whichtests = ::std::stoi(argv[1]);
6365 }
6466 if (whichtests & 0x1) {
6567 cout << " Do nothing calls per second: "
66- << calls_per_second([]() { }, 5) << '\n';
68+ << setw(10) << calls_per_second([]() { }, 5) << '\n';
6769 }
6870 if (whichtests & 0x2) {
6971 cout << " Empty calls per second: "
70- << calls_per_second([]() { do_something(); }, 5) << '\n';
72+ << setw(10) << calls_per_second([]() { do_something(); }, 5) << '\n';
7173 }
7274 if (whichtests & 0x4) {
7375 cout << " New thread calls per second: "
74- << calls_per_second(
76+ << setw(10) << calls_per_second(
7577 []() {
7678 thread t{ do_something };
7779 t.join();
@@ -82,7 +84,7 @@
8284 }
8385 if (whichtests & 0x8) {
8486 cout << " Async launch calls per second: "
85- << calls_per_second(
87+ << setw(10) << calls_per_second(
8688 []() {
8789 auto fut = async(launch::async | launch::deferred, do_something);
8890 fut.wait();
@@ -96,7 +98,7 @@
9698 ::moodycamel::BlockingReaderWriterQueue<bool> to_main;
9799 thread worker{ [&from_main, &to_main]() { worker_thread(from_main, to_main); } };
98100 cout << "Worker thread calls per second: "
99- << calls_per_second(
101+ << setw(10) << calls_per_second(
100102 [&from_main, &to_main]() {
101103 if (!from_main.enqueue(do_something)) {
102104 throw ::std::runtime_error("Unable to send request to worker.");