title: Selenium Headless chrome runs much slower
body: <p>I have a class for Selenium parser:</p>
  <pre class="lang-py prettyprint-override"><code>class DynamicParser(Parser):
      &quot;&quot;&quot;Selenium Parser with processing JS&quot;&quot;&quot;
      driver: Chrome = None
  
      def __init__(self, driver_path='./chromedriver', headless=True):
          chrome_options = Options()
          if headless:
              chrome_options.add_argument(&quot;--headless&quot;)
              chrome_options.add_argument(&quot;window-size=1920,1080&quot;)
  
          # bypass OS security
          chrome_options.add_argument('--no-sandbox')
          # overcome limited resources
          chrome_options.add_argument('--disable-dev-shm-usage')
          # don't tell chrome that it is automated
          chrome_options.add_experimental_option(
              &quot;excludeSwitches&quot;, [&quot;enable-automation&quot;])
          chrome_options.add_experimental_option('useAutomationExtension', False)
          # disable images
          prefs = {&quot;profile.managed_default_content_settings.images&quot;: 2}
          chrome_options.add_experimental_option(&quot;prefs&quot;, prefs)
  
          # Setting Capabilities
          capabilities = DesiredCapabilities.CHROME.copy()
          capabilities['acceptSslCerts'] = True
          capabilities['acceptInsecureCerts'] = True
  
          self.driver = Chrome(chrome_options=chrome_options,
                               executable_path=driver_path, desired_capabilities=capabilities)
  
      def goto(self, url: str):
          &quot;&quot;&quot;Goes to specified URL&quot;&quot;&quot;
          self.driver.get(url)
  
      def get_seller_name(self) -&gt; str:
          &quot;&quot;&quot;Returns seller's name&quot;&quot;&quot;
          offer_actions_tag = self.driver.find_element_by_class_name(
              'offer-user__actions')
          profile_link_tag = offer_actions_tag.find_element_by_tag_name('a')
          return profile_link_tag.text.strip()
  </code></pre>
  <p>Also I have a test script, which creates <code>DynamicParser</code>, goes to some page and calls <code>.get_seller_name()</code>.</p>
  <p>I noticed that when I run Chromedriver headless, it runs much slower, so i tested it using <code>time python3 test.py</code>.</p>
  <p>Output for headless chrome:</p>
  <pre><code>python3 test.py  2,98s user 0,94s system 3% cpu 2:04,65 total
  </code></pre>
  <p>Output for non-headless chrome:</p>
  <pre><code>python3 test.py  1,48s user 0,33s system 47% cpu 3,790 total
  </code></pre>
  <p>As we can see, headless chrome runs almost 33 times slower!</p>
  <p>Chrome version: <code>83.0.4103.116</code></p>
  <p>Chromedriver version: <code>83.0.4103.39</code></p>
  <p>I don't really understand what's the problem. When I developed my previous application, headless chrome worked fast enough.</p>