Jonna Marie Matthiesen Claude Fable 5 commited on
Commit
9962162
Β·
1 Parent(s): 8d85328

Place VS BASE column directly after the metric it compares

Browse files

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AGJFdqmf4AXcsYvb56LLCC

Files changed (2) hide show
  1. app.js +11 -4
  2. speedup.js +9 -3
app.js CHANGED
@@ -761,8 +761,12 @@ function buildTables(filtered, chartsShown) {
761
  return metricHib ? va - vb : vb - va;
762
  });
763
 
764
- // [speedup] pair optimized rows with their baseline for this table
 
 
765
  speedup.prepare(rows, { tableGroupCols, visibleMetrics, activeMetricCol });
 
 
766
 
767
  // Track row group for break detection
768
  let prevGroupVal = undefined;
@@ -778,9 +782,11 @@ function buildTables(filtered, chartsShown) {
778
  html += colDefs.map((c, i) => {
779
  const tip = c.description ? ` data-tip="${c.description.replace(/"/g, '&quot;')}"` : '';
780
  const cls = i === firstMetricIdx ? ' class="first-metric metric-cell"' : (c.isMetric ? ' class="metric-cell"' : '');
781
- return `<th${tip}${cls}>${c.label}</th>`;
 
 
782
  }).join("");
783
- html += speedup.headerHtml(); // [speedup] extra right-hand column
784
  html += `</tr></thead><tbody>`;
785
 
786
  // Compute best metric value per sub-group (tableGroupBy) per column
@@ -826,8 +832,9 @@ function buildTables(filtered, chartsShown) {
826
  } else {
827
  html += `<td>${val || "β€”"}</td>`;
828
  }
 
829
  });
830
- html += speedup.cellHtml(r); // [speedup] extra right-hand column
831
  html += "</tr>";
832
  });
833
 
 
761
  return metricHib ? va - vb : vb - va;
762
  });
763
 
764
+ // [speedup] pair optimized rows with their baseline for this table.
765
+ // The column is inserted right after the metric it compares (falls
766
+ // back to the far right if that metric is somehow not rendered).
767
  speedup.prepare(rows, { tableGroupCols, visibleMetrics, activeMetricCol });
768
+ const speedupAfterCol = colDefs.some(c => c.key === speedup.metricCol())
769
+ ? speedup.metricCol() : null;
770
 
771
  // Track row group for break detection
772
  let prevGroupVal = undefined;
 
782
  html += colDefs.map((c, i) => {
783
  const tip = c.description ? ` data-tip="${c.description.replace(/"/g, '&quot;')}"` : '';
784
  const cls = i === firstMetricIdx ? ' class="first-metric metric-cell"' : (c.isMetric ? ' class="metric-cell"' : '');
785
+ let cell = `<th${tip}${cls}>${c.label}</th>`;
786
+ if (c.key === speedupAfterCol) cell += speedup.headerHtml(); // [speedup]
787
+ return cell;
788
  }).join("");
789
+ if (!speedupAfterCol) html += speedup.headerHtml(); // [speedup] fallback
790
  html += `</tr></thead><tbody>`;
791
 
792
  // Compute best metric value per sub-group (tableGroupBy) per column
 
832
  } else {
833
  html += `<td>${val || "β€”"}</td>`;
834
  }
835
+ if (c.key === speedupAfterCol) html += speedup.cellHtml(r); // [speedup]
836
  });
837
+ if (!speedupAfterCol) html += speedup.cellHtml(r); // [speedup] fallback
838
  html += "</tr>";
839
  });
840
 
speedup.js CHANGED
@@ -1,13 +1,13 @@
1
  // ─── Speedup vs Baseline Column ──────────────────────────────────────────────
2
  //
3
  // Extracted module. Call initSpeedup(deps) from the main app once globals are
4
- // ready. Returns { prepare, headerHtml, cellHtml }.
5
  //
6
  // The benchmark data is inherently paired: an external baseline model (e.g.
7
  // meta-llama/Llama-3.2-1B-Instruct) and the optimized embedl variants of it
8
  // (embedl/Llama-3.2-1B-Instruct-FlashHead, …) measured under identical
9
  // conditions. This module pairs them up and renders their ratio for the
10
- // active metric as an extra right-hand column in the benchmark tables.
11
 
12
  // eslint-disable-next-line no-unused-vars
13
  function initSpeedup(deps) {
@@ -99,6 +99,12 @@ function prepare(rows, opts) {
99
 
100
  // ─── Rendering ───────────────────────────────────────────────────────────────
101
 
 
 
 
 
 
 
102
  function headerHtml() {
103
  if (!state) return "";
104
  const m = state.metricCfg;
@@ -122,6 +128,6 @@ function cellHtml(row) {
122
  + `<span class="speedup-val${down}">${formatRatio(ratio)}</span></td>`;
123
  }
124
 
125
- return { prepare, headerHtml, cellHtml };
126
 
127
  }
 
1
  // ─── Speedup vs Baseline Column ──────────────────────────────────────────────
2
  //
3
  // Extracted module. Call initSpeedup(deps) from the main app once globals are
4
+ // ready. Returns { prepare, headerHtml, cellHtml, metricCol }.
5
  //
6
  // The benchmark data is inherently paired: an external baseline model (e.g.
7
  // meta-llama/Llama-3.2-1B-Instruct) and the optimized embedl variants of it
8
  // (embedl/Llama-3.2-1B-Instruct-FlashHead, …) measured under identical
9
  // conditions. This module pairs them up and renders their ratio for the
10
+ // active metric as an extra column right after that metric in the tables.
11
 
12
  // eslint-disable-next-line no-unused-vars
13
  function initSpeedup(deps) {
 
99
 
100
  // ─── Rendering ───────────────────────────────────────────────────────────────
101
 
102
+ /** Column key of the metric the ratio is based on, so the table can place the
103
+ * speedup column right next to it. Null when the column is not shown. */
104
+ function metricCol() {
105
+ return state ? state.metricCfg.column : null;
106
+ }
107
+
108
  function headerHtml() {
109
  if (!state) return "";
110
  const m = state.metricCfg;
 
128
  + `<span class="speedup-val${down}">${formatRatio(ratio)}</span></td>`;
129
  }
130
 
131
+ return { prepare, headerHtml, cellHtml, metricCol };
132
 
133
  }