0
node
スクリプトを実行しています。chromedriver
が私のウェブサイトで指し示しており、ページの一番下までスクロールし、トレースをtrace.json
に書き込みます。ChromeDriverによって書かれたtrace.jsonの使用方法
このファイルのサイズは約30MBです。
私はこのファイルをに読み込めないようです。プロファイルデータを表示するためにこのファイルを読み込むことはできません。
私のtrace.json
ファイルを理解するための選択肢は何ですか?あなたのスクリプトが正しい形式を生成しない
'use strict';
var fs = require('fs');
var wd = require('wd');
var b = wd.promiseRemote('http://localhost:9515');
b.init({
browserName: 'chrome',
chromeOptions: {
perfLoggingPrefs: {
'traceCategories': 'toplevel,disabled-by-default-devtools.timeline.frame,blink.console,disabled-by-default-devtools.timeline,benchmark'
},
args: ['--enable-gpu-benchmarking', '--enable-thread-composting']
},
loggingPrefs: {
performance: 'ALL'
}
}).then(function() {
return b.get('http://www.example.com');
}).then(function() {
// We only want to measure interaction, so getting a log once here
// flushes any previous tracing logs we have.
return b.log('performance');
}).then(function() {
// Smooth scroll to bottom.
return b.execute(`
var height = Math.max(document.documentElement.scrollHeight, document.body.scrollHeight, document.documentElement.clientHeight);
chrome.gpuBenchmarking.smoothScrollBy(height, function(){});
`);
}).then(function() {
// Wait for the above action to complete.
return b.sleep(5000);
}).then(function() {
// Get all the trace logs since last time log('performance') was called.
return b.log('performance');
}).then(function (data) {
// Write the file to disk.
return fs.writeFileSync('trace.json', JSON.stringify(data.map(function (s) {
return JSON.parse(s.message); // This is needed since Selenium outputs logs as strings.
})));
}).fin(function() {
return b.quit();
}).done();
がファイルで正しく生成されましたか?手動で読み込むことはできますか? –
手動で読み込む方法は?ファイル自体は巨大であるため、正しく生成されているかどうかは分かりませんが、「見た目は良いです」。適切なJSONなど – jerome
手動でロードするには:Chromeを起動し、chrome:// tracing /に移動し、「読み込み」をクリックします。 –