1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

[検証]Puppeteerの接続 〜対象ページでの違い〜

Last updated at Posted at 2019-03-05

はじめに

編集中で解説がまだ記載できておりませんが、先にコードだけ共有しておきます。

今回のコード

接続時間の検証コード
const puppeteer = require('puppeteer');

(async() => {
    const url = [
        'https://www.google.com/',
        'https://www.yahoo.co.jp/',
        'https://qiita.com/',
        'https://github.com/',
        'https://www.rakuten.co.jp/',
    ];

    const browser = await puppeteer.launch();
    const page = await browser.newPage();

    for (let i = 0; i < 5; i++){
        console.log(url[i] + 'に接続中')
        console.time('接続までの時間');
        await page.goto(url[i]); // ページへ
        console.timeEnd('接続までの時間');
    }
    

// puppeteerを終了
await browser.close();
})();
実行結果(1回目)
https://www.google.com/に接続中
接続までの時間: 1190.734ms

https://www.yahoo.co.jp/に接続中
接続までの時間: 1360.209ms

https://qiita.com/に接続中
接続までの時間: 4163.477ms

https://github.com/に接続中
接続までの時間: 2957.095ms

https://www.rakuten.co.jp/に接続中
接続までの時間: 20221.243ms
実行結果(2回目)
// https://www.google.com/に接続中
// 接続までの時間: 1194.058ms

// https://www.yahoo.co.jp/に接続中
// 接続までの時間: 2463.839ms

// https://qiita.com/に接続中
// 接続までの時間: 1958.890ms

// https://github.com/に接続中
// 接続までの時間: 2816.664ms

// https://www.rakuten.co.jp/に接続中
// 接続までの時間: 20071.951ms
実行結果(3回目)
// https://www.google.com/に接続中
// 接続までの時間: 1171.473ms

// https://www.yahoo.co.jp/に接続中
// 接続までの時間: 1387.476ms

// https://qiita.com/に接続中
// 接続までの時間: 2444.999ms

// https://github.com/に接続中
// 接続までの時間: 2725.922ms

// https://www.rakuten.co.jp/に接続中
// 接続までの時間: 19709.615ms

考察

楽天が圧倒的に遅い。
平均値で見ると、おそらくgoogleの接続時間の10倍ほどかかっている。

ヘッドレスブラウザとはいえ、情報量の重いページは接続が遅いと思われる。
(編集中)

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?