• R/O
  • SSH

Commit

Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#objective-cqt誰得cocoawindowspythonphprubygameguibathyscaphec翻訳omegat計画中(planning stage)frameworktwittertestdombtronvb.netdirectxarduinopreviewerゲームエンジン

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


Commit MetaInfo

Révision409f9b966f3094467094eb3685daee1018a3adbd (tree)
l'heure2017-06-03 09:47:40
AuteurEric Hopper <hopper@omni...>
CommiterEric Hopper

Message de Log

Add in system for selecting subset of tests.

Change Summary

Modification

diff -r 76283aa87338 -r 409f9b966f30 test_thread.cpp
--- a/test_thread.cpp Fri Jun 02 17:47:21 2017 -0700
+++ b/test_thread.cpp Fri Jun 02 17:47:40 2017 -0700
@@ -4,6 +4,7 @@
44 #include <iostream>
55 #include "readerwriterqueue.h"
66 #include <stdexcept>
7+#include <string>
78
89 extern void do_something();
910
@@ -50,35 +51,47 @@
5051 }
5152 }
5253
53-int main()
54+int main(int argc, const char * const argv[])
5455 {
5556 using ::std::cout;
5657 using ::std::async;
5758 using ::std::thread;
5859 using ::std::launch;
59- cout << " Do nothing calls per second: "
60- << calls_per_second([]() { }, 5) << '\n';
61- cout << " Empty calls per second: "
62- << calls_per_second([]() { do_something(); }, 5) << '\n';
63- cout << " New thread calls per second: "
64- << calls_per_second(
60+ int whichtests = 31; // All of them, a bitmask.
61+ if (argc > 1) {
62+ whichtests = ::std::stoi(argv[1]);
63+ }
64+ if (whichtests & 0x1) {
65+ cout << " Do nothing calls per second: "
66+ << calls_per_second([]() { }, 5) << '\n';
67+ }
68+ if (whichtests & 0x2) {
69+ cout << " Empty calls per second: "
70+ << calls_per_second([]() { do_something(); }, 5) << '\n';
71+ }
72+ if (whichtests & 0x4) {
73+ cout << " New thread calls per second: "
74+ << calls_per_second(
6575 []() {
6676 thread t{ do_something };
6777 t.join();
6878 },
6979 5
70- )
71- << '\n';
72- cout << " Async launch calls per second: "
73- << calls_per_second(
80+ )
81+ << '\n';
82+ }
83+ if (whichtests & 0x8) {
84+ cout << " Async launch calls per second: "
85+ << calls_per_second(
7486 []() {
7587 auto fut = async(launch::async | launch::deferred, do_something);
7688 fut.wait();
7789 },
7890 5
79- )
80- << '\n';
81- {
91+ )
92+ << '\n';
93+ }
94+ if (whichtests & 0x10) {
8295 ::moodycamel::BlockingReaderWriterQueue<the_call_t> from_main;
8396 ::moodycamel::BlockingReaderWriterQueue<bool> to_main;
8497 thread worker{ [&from_main, &to_main]() { worker_thread(from_main, to_main); } };