<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>hidemon</author_name>
  <author_url>https://blog.hatena.ne.jp/hidemon/</author_url>
  <blog_title>hidemonのブログ</blog_title>
  <blog_url>https://hidemon.hatenadiary.jp/</blog_url>
  <categories>
    <anon>go</anon>
  </categories>
  <description>Goではチャンネルをいろいろな目的に使うことが推奨されている。pythonならgeneratorで書くようなこともgoroutineとチャンネルでやる。確かに書きやすくはなるのだろうけど、どの程度オーバヘッドがあるのか調べてみた。 調べること プロデューサとコンシューマをそれぞれ別のgoroutineで動かしておいて、その間に64bit intをひとつずつ流す。バッファなしのチャネルなので、1つ流れるごとにgoroutine間のコンテクストスイッチが起こる。これを単純な関数呼び出しのオーバヘッドと比較する。 チャンネルを使ったコード package main import &quot;fmt&quot; func…</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Fhidemon.hatenadiary.jp%2Fentry%2F20101026%2F1288092723&quot; title=&quot;Go のチャンネルオーバヘッド - hidemonのブログ&quot; class=&quot;embed-card embed-blogcard&quot; scrolling=&quot;no&quot; frameborder=&quot;0&quot; style=&quot;display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;&quot;&gt;&lt;/iframe&gt;</html>
  <image_url></image_url>
  <provider_name>Hatena Blog</provider_name>
  <provider_url>https://hatena.blog</provider_url>
  <published>2010-10-26 20:32:03</published>
  <title>Go のチャンネルオーバヘッド</title>
  <type>rich</type>
  <url>https://hidemon.hatenadiary.jp/entry/20101026/1288092723</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
