@@ -51,9 +51,8 @@ async function process_chunks (path) {
5151 const scored_chunk = process_raw_results ( chunk_run )
5252 if ( ! result . run_info ) {
5353 const raw_run_info = scored_chunk . run_info
54- const matches = raw_run_info
55- . browser_version . match ( / ^ S e r v o ( [ 0 - 9 . ] + - [ a - f 0 - 9 ] + ) ? ( - d i r t y ) ? $ / )
56- const browser_version = matches . length === 3 ? matches [ 1 ] : 'Unknown'
54+ const matches = raw_run_info ?. browser_version ?. match ( / ^ S e r v o ( [ 0 - 9 . ] + - [ a - f 0 - 9 ] + ) ? ( - d i r t y ) ? $ / )
55+ const browser_version = matches ?. length === 3 ? matches [ 1 ] : 'Unknown'
5756 result . run_info = Object . assign ( raw_run_info , { browser_version } )
5857 }
5958 delete scored_chunk . run_info
@@ -67,6 +66,23 @@ async function add_run (runs_dir, chunks_dir, date) {
6766 await write_compressed ( `./${ runs_dir } /${ date } .xz` , new_run )
6867}
6968
69+ async function score_single_run ( chunks_dir ) {
70+ const run = await process_chunks ( chunks_dir )
71+ const test_to_areas = focus_areas_map ( run )
72+ const { area_keys } = get_focus_areas ( )
73+ const score = score_run ( run , run , test_to_areas )
74+ const row = [
75+ [ 'revision' , run . run_info . revision . substring ( 0 , 9 ) ] ,
76+ [ 'browser version' , run . run_info . browser_version ]
77+ ]
78+
79+ for ( const area of area_keys ) {
80+ row . push ( [ area , score [ area ] ] )
81+ }
82+
83+ return row
84+ }
85+
7086async function recalc_scores ( runs_dir ) {
7187 console . log ( `Calculating scores for ${ runs_dir } directory...` )
7288
@@ -102,10 +118,17 @@ async function recalc_scores (runs_dir) {
102118
103119async function main ( ) {
104120 const mode = process . argv [ 2 ]
105- if ( ! [ '--add' , '--recalc' ] . includes ( mode ) ) {
121+ if ( ! [ '--add' , '--recalc' , '--score' ] . includes ( mode ) ) {
106122 throw new Error ( `invalid mode specified: ${ mode } ` )
107123 }
108124
125+ if ( mode === '--score' ) {
126+ const input_dir = process . argv [ 3 ]
127+ const result = await score_single_run ( input_dir )
128+ console . log ( result )
129+ return
130+ }
131+
109132 if ( mode === '--add' ) {
110133 const chunks_2013 = process . argv [ 3 ]
111134 const chunks_2020 = process . argv [ 4 ]
0 commit comments