@condenast/perf-timeline-cli

0.1.3 • Public • Published

Perf Timeline CLI

A command line interface for generating Chrome Performance timelines.

License GitHub package version Build status Coverage status Dependencies Dev Dependencies

Proudly built by:

Demo

Generate a timeline, see how many Layout events occurred, and get the total JavaScript execution time using Big Rig.

Command line demo SVG

Motivations

Chrome DevTools' Performance panel is an industry standard for creating page load timelines to understand how a website renders. As nice as it is to be able to click a few buttons to generate a timeline, creating a Performance timeline from the command line extends the functionality to fit different workflows.

Prior to building this tool, I struggled with a few issues when generating timelines from the Chrome DevTools Performance panel.

  1. The UI is sometimes slow and unresponsive, especially when debugging sites with high CPU usage.
  2. Due to the way that some sites are constructed, it is hard to get a "clean" timeline. If you load a page, then hit the "Start profiling and reload page" button, your timeline often includes trace events for the unloading of the current page.
  3. It is not possible to programmatically generate timelines. For instance, when trying to find a performance regression, you may want to generate a timeline for the last 10 builds of a project. This task requires a lot of extra UI steps within DevTools.

Perf Timeline attempts to improve the developer experience by providing a fast interface to generate clean Performance timelines.

Prerequisites

Perf Timeline CLI requires Node 8+ and a current version of Chrome to view generated timelines.

Install

npm install -g @condenast/perf-timeline-cli

Usage

Generate a Performance timeline using defaults

perf-timeline generate https://www.wired.com

Generate a Performance timeline while throttling network

perf-timeline generate https://www.wired.com \
  --emulate-network-conditions \
  --latency 150 \
  --upload-throughput 0.75 \
  --download--throughput 1.6

Generate a Performance timeline while throttling CPU

perf-timeline generate https://www.wired.com \
  --set-cpu-throttling-rate \
  --rate 4

Generate a Performance timeline with screenshots

perf-timeline generate https://www.wired.com \
  --screenshots

Generate a Performance timeline and save to a custom location

perf-timeline generate https://www.wired.com \
  --path ~/my-timeline.json

Commands

generate

generate creates a Performance timeline for the URL passed to the command. The timeline is saved as trace.json in the current directory. The timeline conditions can be adjusted using the arguments documented below.

Positional

  • url (required; no default) - URL used to generate the Performance timeline

Launch Options

Launch options are passed to the puppeteer.launch() command. Not all options are currently supported. Supported options are listed below. For more information, please see the Puppeteer Documentation.

  • --ignore-https-errors (optional; false) - When --ignore-https-errors is passed, an HTTPS errors will be ignored. This causes Chrome's default error behaviors when encountering HTTPS issues to be ignored.
  • --headless (options; true) - By default, Perf Timeline CLI runs in "headless" mode (i.e., without a visible browser UI). To see a browser UI when generating the timeline, pass the --headless false to the generate command. Please note that --no-headless is a synonym for --headless false.

Network Emulation Options

The Network Emulation Options allow you to generate a Performance timeline under specified network conditions. To turn on network emulation, you must pass the --emulate-network-conditions flag along with additional configuration options. These options mirror Chrome Headless' emulateNetworkConditions arguments. All options are supported. Note that some arguments have been augmented for the CLI use case to improve the product experience (e.g., throughout arguments us megabits per second instead of bytes per second).

  • --emulate-network-conditions (optional; false) - In order to set network conditions for a timeline generation session, you must pass the --emulate-network-conditions flag. This flag allows the other Network Emulation Options to be respected. They will be completely ignored unless this flag is set.
  • --offline (optional; false) - Passing the --offline flag to the generate command emulate a network disconnect.
  • --latency (optional; 0) - Artificial, minimum latency between request sent and response header received expressed in milliseconds (ms).
  • --download-throughput (optional: -1) - The maximum download speed in megabits per second. Note Chrome Headless' version of this argument uses bytes per second. Perf Timeline CLI uses megabits per second as that is a more common measure of network throughput. -1 disables throttling.
  • --upload-throughput (optional: -1) - The maximum upload speed in megabits per second. Note Chrome Headless' version of this argument uses bytes per second. Perf Timeline CLI uses megabits per second as that is a more common measure of network throughput.-1 disables throttling.
  • --connection-type (optional: none) - A label of the supposed underlying network connection type that the browser is using. Supported values are documented under Chrome Headless' ConnectType documentation.

Set CPU Throttling Rate Options

The Set CPU Throttling Rate Emulation Options allow you to generate a Performance timeline under specified CPU conditions. To turn on CPU emulation, you must pass the --set-cpu-throttling-rate flag along with additional configuration options. These options mirror Chrome Headless' setCPUThrottlingRate arguments. All options are supported.

  • --set-cpu-throttling-rate (optional; false) - In order to set network conditions for a timeline generation session, you must pass the --set-cpu-throttling-rate flag. This flag allows the other Set CPU Throttling Rate Options to be respected. They will be completely ignored unless this flag is set.
  • --rate (optional; 1) - Sets the CPU throttling rate. The number represents the slowdown factor (e.g., 2 is a "2x" slowdown).

Goto Options

The Goto Options mirror the page.goto() method's options from Puppeteer. These options allow you to configure how the page navigation is handled. All options are currently supported. Note that the url option for page.goto is provided by the url, positional argument passed to generate. You cannot override that option here. See the page.goto documentation for more details.

  • --timeout (optional; 30) - Maximum time in seconds to load the page until the timeline generation is stopped. Note that if you emulate the network or CPU, or if you set later --wait-until values, you should increase --timeout to improve the chances of successfully generating a timeline.
  • --wait-until (optional; load) - The success event for the navigation. Puppeteer "waits until" this event has occurred to finish the timeline. load, domcontentloaded, networkidle0, and networkidle2 are supported. Note that --timeout takes precedence over --wait-until. If the --wait-until event has not occurred before the --timeout time is reached, an error is thrown and no timeline will be generated.

Tracing Options

The Tracing Options allow to you configure the options for Puppeteer's page.tracing.start() method. All options are supported. See the page.tracing.start documentation for more details.

  • --path (optional; ./trace.json) - The file path for where to save the trace.
  • --screenshots (optional; false) - Passing the --screenshots flag causes Chrome to take screenshots of the page as the timeline is generated. These screenshots are embedded in the tracing file and are shown in DevTools when viewing the Performance timeline.
  • --categories (optional; []) - The list of trace event categories to capture in the timeline. This argument is passed as a comma separated list of categories. This option is useful if you wish to reduce the overall size of the trace file. Note that limiting to certain categories only can leave you with a timeline that does not appear to show anything when viewing in DevTools' Performance panel. The best way to see the possible categories is to view a raw trace and look for the cat value of events.

Thanks

This project is built on the shoulders of giants. It's nothing more than a convenience wrapper around some really exciting projects, including:

Contributors

See the list of contributors who participated in writing this tool.

Package Sidebar

Install

npm i @condenast/perf-timeline-cli

Weekly Downloads

51

Version

0.1.3

License

Apache-2.0

Unpacked Size

36.7 kB

Total Files

19

Last publish

Collaborators

  • sreenu-condenast
  • ronjr_owlbear
  • boygao1992
  • saikat_conde
  • ashanatesh
  • priyadarshinitao
  • naresh.kandhan
  • deepakmohan
  • husnabushra
  • ramjeetm
  • imleodc
  • skumar3conde
  • mounika-boyapati
  • nagaraja_h
  • jasonmarlin
  • arunconde
  • roberlander
  • josemanuel.barea.ortiz
  • nprabhu-cn
  • sahildshah1
  • jmundycn
  • juliendevlin
  • sheetalparsa
  • unviradiya
  • ssingh417
  • dev-anand-94
  • vinitha_thiagarajan
  • prasil1107
  • rgunton-conde
  • swarupshankar
  • areadman
  • abhishek_pandey_cn
  • vchand-cn
  • harsh_condenast
  • swati_verso
  • samruddhidube24
  • gapurdev
  • akshayjain10
  • utkarsh24
  • suma_k
  • mohnish_vurity
  • piyush_das
  • kshitiz_choudhary
  • cnmanju
  • vvkudachi
  • vijeshrj
  • jkraus
  • vaseemakram
  • sharvanipatil
  • cn-rahul-tiwari
  • dhanashri027
  • mukarthik
  • blue-rigel
  • mguyromelle
  • bharathikarunanithi
  • cn_priyanka14
  • mehulpiruka
  • kishor-kumar07
  • ngsangeeta
  • prashant_singhparihar
  • snehak
  • shrutinivedita
  • sandhya_rani
  • cedric_mascarenhas
  • m-mallikarjuna
  • imran-conde
  • smantriconde
  • machelslackatcondenast
  • sachin-ns
  • jorge_guerra2
  • pratima_cn
  • harsha_mahadevaiah
  • richa_cn
  • karthik_cn
  • muthuprakashvelumani
  • imleo_conde
  • issanjana
  • a-rena
  • colin-alexa
  • bxh-io-cn
  • benknowlesnews
  • timklimowicz
  • ramkun
  • kamal_conde
  • aditijhacn
  • namansingh_bhandari
  • max-prin
  • cnarkhede
  • nrajeshnpm
  • vinothkumar_bala
  • aksingh5
  • shashank_jaiswal
  • saicharan7766
  • vineethd
  • hebsibal_selvaraj
  • akeshavamurthy
  • priyanka_jha
  • saniyashk
  • jbs-cn
  • gargi-c
  • hippolin
  • klnarayanan
  • cn_joy_sen
  • cn-andres
  • ganavi_j
  • sellapandi1998
  • jsharma-cn
  • spoorthi.chandrashekar
  • venkatesh547
  • dinakar25
  • hegdem
  • erikveland
  • asinghconde
  • joselee43
  • eunianina
  • gchaithra
  • patternwise
  • omar.wl
  • andrixb
  • raxs
  • vivekans
  • susel_retana
  • praveenppk
  • rafalpuche
  • conde_jode
  • subbiah_ramakrishna
  • fernandolara23
  • sarahshincn
  • jordi.escude
  • nnasirov
  • unnatik
  • tania.delatorre
  • mniewiera-cn
  • vinayashreeram
  • mohitsharma-news
  • aaaanti
  • psundar
  • wljoel
  • arhovale
  • sgdurham
  • fsanchezvilela
  • alfonsocondenast
  • rashmicn
  • slarty667
  • christinahara
  • nanjacn
  • siddhu-23
  • atp-engineering
  • katiasfihi
  • luisenriquegutierrez
  • akhil_npm_condenast
  • danj-cn
  • sudeshna_cn
  • vikash_cn
  • lakshmi.priya
  • sumanth_cn
  • shahu_cn
  • utsav_cn
  • mmorris9
  • maila-labib
  • mala-shanbhag
  • anilc93
  • lavishgambhir
  • vmanzanilla
  • tdscondenast
  • nitish-tandia
  • murali-condenast
  • alejandroaltf4dev
  • omsun22
  • ksriniva2
  • aleccuster_cn
  • andregcab
  • bhoopalt
  • niclasbork
  • pramita21
  • tchathur
  • kangkanbora
  • suhas-cn
  • vinay-pr
  • rjcn
  • vikramchowdary_parimi
  • sugumarv
  • josephrussell-cn
  • seking31
  • eliza.nieves
  • anaedzm
  • naveen1601
  • kajal-sikka
  • cn-connorbrannigan
  • prajwal_keshav
  • arjunpa
  • sharique10
  • babincondenast
  • cn-oramirez
  • guru05111984
  • subinjoeconde
  • edistel
  • saahithisri
  • balar20
  • s_dwivedi
  • nhrqz
  • monicar
  • richsancho
  • tanya-sah
  • cn_jenkins
  • frandevinney
  • renovate
  • jyoti_3009
  • r0r71z
  • jaemega
  • aman-shinde-07
  • condenastadmin
  • angrymongoose
  • copilot-robot
  • cry4dawn_2000
  • fennen529
  • fmadrie
  • gkilian
  • gmedina
  • bigzed
  • raagul-conde
  • stan
  • stanley
  • andi.anderson522
  • tamal_banerjee
  • davidkofahl
  • biku
  • taniabhullar
  • dkorenblyum
  • tollmanz
  • amalamchtal
  • tdshap
  • nidhi-tcs
  • rishutcs
  • sayeedcn
  • pitchfork-dev
  • danhaller
  • rajasinghcondenast
  • derrickatcn
  • tce
  • lboylan
  • cnid_engineering
  • lilyhealey
  • varun9110
  • megrymo
  • prajaktak
  • manthanbhosle
  • rutujavetal
  • niharanil
  • psharma2
  • bhumikakhatri
  • sarthak_mohanty
  • igostu
  • rajashreearvikar19
  • tobe998
  • cwoldt
  • ndi
  • nishkala
  • sahana2104
  • mladhane
  • mtzhang
  • manthanraut
  • jfrederick12
  • rajashree-devaraj
  • sdconde
  • rigelsong
  • drosenbaum
  • roopeshrkn
  • aswani_gupta
  • garryyao
  • charuagrawal
  • sabarni-condenast
  • yakshita
  • kalyanikasar
  • talk2rajeev
  • shreyapa
  • stefanpenner
  • natelawscn
  • bbui
  • alexli
  • brian_mathews
  • crmartin
  • leahzxxz
  • hmehta06
  • srigurutcs
  • husheric
  • katemont
  • eddleston
  • rtt
  • eshno
  • jcorcino
  • anwaukoni
  • richardsjustind
  • eduardoveras
  • mrgentax
  • thehiddenhaku
  • cl4m
  • spollini
  • fedeava
  • sasha04
  • guidop91
  • gostfield
  • nithya10
  • satnam_gandhi
  • abigaild45
  • mb_dev
  • rmohamma
  • emilyatk
  • asolovyev
  • vaishnavisenthilvel
  • stefano-sarioli
  • sarah-chekfa
  • luis_gomez
  • danielbaldwin
  • karmenn
  • khiaraortiz
  • dmitriy_komarov-cn
  • jhraue
  • sviatoslav_maslov
  • hcet
  • jmcamacho
  • ishita_tiwari
  • sanjana_s
  • hariprasath_cn
  • harinikiruba
  • condenastfr
  • iamsuneeth
  • suhitrathi-condenast
  • zeeshan-wani
  • imakshath
  • srikanthns
  • mitchellstewart
  • pushp-1992
  • anoopk-cn
  • mithunsathyanmits
  • surbhi_cn
  • vikasshetty
  • midhunmurali001
  • sudiptacondenast
  • salvador-ahumada
  • suba56
  • skt-dev
  • ganeshnca
  • belal_kazmi
  • rszmacinski
  • prakashn37
  • utkarsh_sanjivan-conde
  • mallica
  • shobith
  • rashmi-rao
  • sahoo.sandhya
  • sardendu
  • agururajan
  • skumari
  • sikindar_mirza
  • ankitkumar02
  • avinash_iitb
  • upenpanging
  • speluri
  • anubalakrishnan
  • sbhattac
  • rjain198
  • ashwini_uppar
  • pmasade
  • jbergdol
  • suresharam
  • vnallasa
  • dhanraj_cn
  • pratik-gupta
  • anita-y
  • arvipandey
  • sandesh4777
  • vishnusimvisfear
  • ilankumaran
  • samtiffin
  • harsha-condenast
  • adityaanand534
  • rkamble
  • chandan-condenast
  • pratham7674
  • alokreddycn
  • anurag-cn
  • odtoribio
  • pranjal_sharma306500
  • vijayalakshmi-sunagar
  • helena-ong
  • namankumarsinha
  • grannitsejdiu
  • rkharecondenast
  • sumitmaurya21
  • pashoka
  • shubham_condenast
  • sourav_condenast
  • tanmoy_condenast
  • nidhiarya-condenast
  • vmehrotr
  • smita2022
  • pariharcondenast
  • subiabre
  • snehadg
  • sourav909
  • surabhidesai
  • syed_faizan
  • raveena-ram
  • statavar
  • jatinbabbarcondenast
  • ankushvijay93
  • likhita
  • indu-sagi
  • jakir-coder
  • priyankanandi
  • nikhilcondenast
  • stahirah
  • sparganiha-cn
  • aswanth_condenast
  • vinay_kumar
  • rajeswari-cn
  • soumyagundu
  • cnrahulrkr
  • ramya-cn
  • dikshita_khandke
  • somsekhardash
  • ambay_chaurasia
  • manikandancn
  • rghvndr99
  • shubhamkheracn
  • akhil_pasham
  • mulla2
  • spandey10
  • srawat-cn