Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(95)

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/timeline/TimelinePanel.js

Issue 1959783002: DevTools: Introduce device dependent CPU throttling rates. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * Copyright (C) 2012 Intel Inc. All rights reserved. 3 * Copyright (C) 2012 Intel Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 this._captureMemorySetting.addChangeListener(this._onModeChanged, this); 399 this._captureMemorySetting.addChangeListener(this._onModeChanged, this);
400 this._captureFilmStripSetting.addChangeListener(this._onModeChanged, thi s); 400 this._captureFilmStripSetting.addChangeListener(this._onModeChanged, thi s);
401 401
402 this._panelToolbar.appendSeparator(); 402 this._panelToolbar.appendSeparator();
403 var garbageCollectButton = new WebInspector.ToolbarButton(WebInspector.U IString("Collect garbage"), "garbage-collect-toolbar-item"); 403 var garbageCollectButton = new WebInspector.ToolbarButton(WebInspector.U IString("Collect garbage"), "garbage-collect-toolbar-item");
404 garbageCollectButton.addEventListener("click", this._garbageCollectButto nClicked, this); 404 garbageCollectButton.addEventListener("click", this._garbageCollectButto nClicked, this);
405 this._panelToolbar.appendToolbarItem(garbageCollectButton); 405 this._panelToolbar.appendToolbarItem(garbageCollectButton);
406 406
407 if (Runtime.experiments.isEnabled("cpuThrottling")) { 407 if (Runtime.experiments.isEnabled("cpuThrottling")) {
408 this._panelToolbar.appendSeparator(); 408 this._panelToolbar.appendSeparator();
409 this._cpuThrottlingCombobox = new WebInspector.ToolbarComboBox(this. _onCPUThrottlingChanged.bind(this)); 409 this._panelToolbar.appendToolbarItem(this._createCPUThrottlingContro l());
410 /**
411 * @param {string} name
412 * @param {number} value
413 * @this {WebInspector.TimelinePanel}
414 */
415 function addGroupingOption(name, value)
416 {
417 var option = this._cpuThrottlingCombobox.createOption(name, "", String(value));
418 this._cpuThrottlingCombobox.addOption(option);
419 if (value === this._cpuThrottlingManager.rate())
420 this._cpuThrottlingCombobox.select(option);
421 }
422 addGroupingOption.call(this, WebInspector.UIString("No CPU throttlin g"), 1);
423 for (var rate of [1.2, 1.5, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 15, 20, 30, 50])
424 addGroupingOption.call(this, WebInspector.UIString("%fx slowdown ", rate), rate);
425 this._panelToolbar.appendToolbarItem(this._cpuThrottlingCombobox);
426 } 410 }
427 }, 411 },
428 412
413 /**
414 * @return {!WebInspector.ToolbarItem}
415 */
416 _createCPUThrottlingControl: function()
417 {
418 var cpuThrottlingManager = this._cpuThrottlingManager;
419 var cpuThrottlingCombobox = new WebInspector.ToolbarComboBox(this._onCPU ThrottlingChanged.bind(this));
420 this._cpuThrottlingCombobox = cpuThrottlingCombobox;
421 /**
422 * @param {string} name
423 * @param {number} value
424 */
425 function addGroupingOption(name, value)
426 {
427 var option = cpuThrottlingCombobox.createOption(name, "", String(val ue));
428 cpuThrottlingCombobox.addOption(option);
429 return option;
430 }
431 function addSeparator()
432 {
433 addGroupingOption("", 0).disabled = true;
434 }
435
436 cpuThrottlingCombobox.select(addGroupingOption(WebInspector.UIString("No CPU throttling"), 1));
437 addSeparator();
438
439 var hostOctaneScore = WebInspector.settings.createSetting("hostOctaneSco re", 0).get();
440 if (hostOctaneScore) {
441 var emulatedDevicesList = WebInspector.EmulatedDevicesList.instance( );
442 var devices = [].concat(emulatedDevicesList.standard(), emulatedDevi cesList.custom());
443 for (var device of devices) {
444 if (!device.octaneScore || device.octaneScore > hostOctaneScore)
445 continue;
446 var rate = hostOctaneScore / device.octaneScore;
447 addGroupingOption(WebInspector.UIString("%s\u2003(%.1fx slowdown )", device.title, rate), rate);
448 }
449 addSeparator();
450 }
451
452 [1.2, 1.5, 2, 3, 4, 5, 8, 10, 15, 20, 30, 50].forEach(rate => addGroupin gOption(WebInspector.UIString("%fx slowdown", rate), rate));
453
454 return cpuThrottlingCombobox;
455 },
456
429 _prepareToLoadTimeline: function() 457 _prepareToLoadTimeline: function()
430 { 458 {
431 console.assert(this._state === WebInspector.TimelinePanel.State.Idle); 459 console.assert(this._state === WebInspector.TimelinePanel.State.Idle);
432 this._setState(WebInspector.TimelinePanel.State.Loading); 460 this._setState(WebInspector.TimelinePanel.State.Loading);
433 }, 461 },
434 462
435 _createFileSelector: function() 463 _createFileSelector: function()
436 { 464 {
437 if (this._fileSelectorElement) 465 if (this._fileSelectorElement)
438 this._fileSelectorElement.remove(); 466 this._fileSelectorElement.remove();
(...skipping 1625 matching lines...) Expand 10 before | Expand all | Expand 10 after
2064 * @override 2092 * @override
2065 * @param {!WebInspector.Target} target 2093 * @param {!WebInspector.Target} target
2066 */ 2094 */
2067 targetRemoved: function(target) 2095 targetRemoved: function(target)
2068 { 2096 {
2069 this._targets.remove(target, true); 2097 this._targets.remove(target, true);
2070 }, 2098 },
2071 2099
2072 __proto__: WebInspector.Object.prototype 2100 __proto__: WebInspector.Object.prototype
2073 } 2101 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698