Goについて扱うスレッドです。
GoはGoogleによって開発された言語です。
公式
https://golang.org
公式ドキュメント
https://golang.org/doc/
公式外パッケージドキュメント
https://godoc.org
ブラウザ上で試し書き
https://play.golang.org
※前スレ
Go language part 3
https://mevius.5ch.net/test/read.cgi/tech/1571315884/
探検
Go language part 4
レス数が1000を超えています。これ以上書き込みはできません。
2020/11/16(月) 04:14:40.64ID:fB5+0hxC
999デフォルトの名無しさん
2022/02/27(日) 08:07:16.26ID:c9v4owXb ワッチョイ無しかー(´・ω・`)
1000デフォルトの名無しさん
2022/02/27(日) 08:16:41.16ID:+yReYAPt goroutineとC++標準ライブラリのスレッドを比較するために>>957のmain.rsのC++版だけ作ってみた(ループは一桁減らした)
$ cat main.cc
#include <thread>
#include <chrono>
#include <vector>
using namespace std;
using namespace std::chrono;
int main() {
vector<unique_ptr<thread>> threads;
for (uint32_t i = 0; i < 1000; ++i) {
threads.emplace_back(
make_unique<thread>([=]{
uint64_t bad_hash = (i * 2654435761) % 200000;
this_thread::sleep_for(microseconds(bad_hash));
for (uint32_t _ = 0; _ < 1000; ++_) {
this_thread::sleep_for(10ms);
}
})
);
}
for (auto const& t: threads) {
t->join();
}
return 0;
}
$ g++ -O3 -pthread main.cc -o main && ./t ./main
real 11.04s
user 0.93s
sys 2.95s
rss 11328k
$
結果はmain.rsとほぼ同じで、やはりスレッド起動コストがデカく、rssもデカい
$ cat main.cc
#include <thread>
#include <chrono>
#include <vector>
using namespace std;
using namespace std::chrono;
int main() {
vector<unique_ptr<thread>> threads;
for (uint32_t i = 0; i < 1000; ++i) {
threads.emplace_back(
make_unique<thread>([=]{
uint64_t bad_hash = (i * 2654435761) % 200000;
this_thread::sleep_for(microseconds(bad_hash));
for (uint32_t _ = 0; _ < 1000; ++_) {
this_thread::sleep_for(10ms);
}
})
);
}
for (auto const& t: threads) {
t->join();
}
return 0;
}
$ g++ -O3 -pthread main.cc -o main && ./t ./main
real 11.04s
user 0.93s
sys 2.95s
rss 11328k
$
結果はmain.rsとほぼ同じで、やはりスレッド起動コストがデカく、rssもデカい
10011001
Over 1000Thread このスレッドは1000を超えました。
新しいスレッドを立ててください。
life time: 468日 4時間 2分 1秒
新しいスレッドを立ててください。
life time: 468日 4時間 2分 1秒
レス数が1000を超えています。これ以上書き込みはできません。
ニュース
- 日銀、0.75%に利上げ - 30年ぶり高水準、物価高抑制 ★3 [ぐれ★]
- 【速報】松本人志、大みそかにテレビ“復帰” [Anonymous★]
- 【不審者】頭髪薄めの男性が児童へ声かけ 「レストランどこ」 名古屋市 [少考さん★]
- 日銀、0.75%に利上げ - 30年ぶり高水準、物価高抑制 ★4 [ぐれ★]
- 【スクープ】敏腕プロデューサーSKY-HIが未成年女性アイドル(17)を深夜に自宅呼び出し、「かわいすぎる死ぬ」「だぁいすき」などのLINEも★3 [Ailuropoda melanoleuca★]
- 【赤坂サウナ火災】「通風口」叩き助け求めたか…夫には広範囲“やけど”の痕あり妻を熱からかばおうと覆い被さった可能性 [ぐれ★]
- 【高市謎】「楽天市場」👈くそ安いです。日本企業です。 ポイントめちゃくちゃ付きます。なのにお前らが利用しない理由ww [921362874]
- 官邸関係者「日本は核保有すべき」発言、ネトウヨの想像してるより大問題に。与野党問わず批判。政府とネトウヨは事の重大性に気付かず [256556981]
- 赤坂サウナ夫婦「だれかあああああああああ!!!!!!」換気口に叫んで助けを求めたと判明 [329329848]
- 【訃報】利上げをして円安へ、1ドル156円 [943688309]
- 殺人サウナの必勝攻略法、見つかるwwwwwwwwwwwwwwwww [977790669]
- 【画像】挟むタイプのピアス買ってみたwwwwwwwwwwwwww
