[Loading benchmark] A small metric refactoring

* Convert proto metrics to plain SQL queries; this way it will be easier
to support them in both TP and Batch TP.
* Unify all metrics to use the same mechanism to determine presentation
time.
* Remove RAF calls from Globo website instrumentation.

Change-Id: Icbdf8f0916c900f0646892ab9bbe25d23e8b407f
Reviewed-on: https://chromium-review.googlesource.com/c/crossbench/+/5826555
Reviewed-by: Igor Kraskevich <kraskevich@google.com>
Commit-Queue: Mikhail Khokhlov <khokhlov@google.com>
diff --git a/config/benchmark/loading/globo_instrumentation.js b/config/benchmark/loading/globo_instrumentation.js
index 39a30b6..91d49e0 100644
--- a/config/benchmark/loading/globo_instrumentation.js
+++ b/config/benchmark/loading/globo_instrumentation.js
@@ -4,19 +4,8 @@
 
 const button_selector = 'button[aria-label=Consent]'
 const banner_selector = 'div[class=fc-consent-root]'
-const menu_button_id = 'menu-toggle'
-const menu_panel_id = 'menu-container'
 var banner_observer;
 
-const two_rafs =
-    function(cb) {
-  window.requestAnimationFrame(function(ts) {
-    window.requestAnimationFrame(function(ts) {
-      cb()
-    })
-  })
-}
-
 const button_observer = new MutationObserver(mutations => {
   const button = document.querySelector(button_selector)
   if (!button) {
@@ -33,19 +22,13 @@
     e.forEach(function(m) {
       m.removedNodes.forEach(function(n) {
         if (n === banner_node) {
-          performance.mark('cookie_banner_deleted')
-          two_rafs(function(ts) {
-            performance.mark('cookie_banner_gone')
-          })
+          performance.mark('cookie_banner_gone')
         }
       })
     })
   });
   banner_observer.observe(banner_node.parentNode, {childList: true});
-  performance.mark('cookie_banner_shown')
-  two_rafs(function(ts) {
-    button.click()
-  })
+  button.click()
 })
 
 button_observer.observe(document, {childList: true, subtree: true});
diff --git a/config/benchmark/loading/probe_config.hjson b/config/benchmark/loading/probe_config.hjson
index d8bad5d..61d332e 100644
--- a/config/benchmark/loading/probe_config.hjson
+++ b/config/benchmark/loading/probe_config.hjson
@@ -3,13 +3,13 @@
     // Uncomment the following line to record a WPR archive.
     // wpr: {},
     trace_processor: {
-      metrics: [
-        "lcp_metric",
-        "amazon_page_load_metric",
-        "cnn_page_load_metric",
-        "globo_page_load_metric",
-        "wikipedia_page_load_metric",
-        "youtube_page_load_metric",
+      queries: [
+        "loading/lcp_metric",
+        "loading/amazon_page_load_metric",
+        "loading/cnn_page_load_metric",
+        "loading/globo_page_load_metric",
+        "loading/wikipedia_page_load_metric",
+        "loading/youtube_page_load_metric",
       ],
     },
     perfetto: {
diff --git a/config/benchmark/loading/probe_config_experimental.hjson b/config/benchmark/loading/probe_config_experimental.hjson
index 2e37366..0914d06 100644
--- a/config/benchmark/loading/probe_config_experimental.hjson
+++ b/config/benchmark/loading/probe_config_experimental.hjson
@@ -3,26 +3,24 @@
 {
   probes: {
     trace_processor: {
-      metrics: [
-        "lcp_metric",
-        "amazon_page_load_metric",
-        "cnn_page_load_metric",
-        "globo_page_load_metric",
-        "wikipedia_page_load_metric",
-        "youtube_page_load_metric",
-      ],
       queries: [
-        "loading/cpu",
-        "loading/dom",
-        "loading/interaction_latency",
-        "loading/mojo",
-        "loading/resources",
-        "loading/sequence_manager",
-        "loading/tlp",
-        "loading/v8",
-        "loading/v8_rcs",
-        "loading/web_features",
-        "loading/worker",
+        "loading/lcp_metric",
+        "loading/amazon_page_load_metric",
+        "loading/cnn_page_load_metric",
+        "loading/globo_page_load_metric",
+        "loading/wikipedia_page_load_metric",
+        "loading/youtube_page_load_metric",
+        "loading/experimental/cpu",
+        "loading/experimental/dom",
+        "loading/experimental/interaction_latency",
+        "loading/experimental/mojo",
+        "loading/experimental/resources",
+        "loading/experimental/sequence_manager",
+        "loading/experimental/tlp",
+        "loading/experimental/v8",
+        "loading/experimental/v8_rcs",
+        "loading/experimental/web_features",
+        "loading/experimental/worker",
       ],
     },
     perfetto: {
diff --git a/crossbench/probes/trace_processor/metrics/protos/amazon_page_load_metric.proto b/crossbench/probes/trace_processor/metrics/protos/amazon_page_load_metric.proto
deleted file mode 100644
index 4778f1d..0000000
--- a/crossbench/probes/trace_processor/metrics/protos/amazon_page_load_metric.proto
+++ /dev/null
@@ -1,15 +0,0 @@
-syntax = "proto2";
-
-package perfetto.protos;
-
-import "protos/perfetto/metrics/metrics.proto";
-
-message AmazonPageLoadMetric {
-  optional double js_ready_ms = 1;
-}
-
-extend TraceMetrics {
-  // The field number range reserved for Chrome metrics is 1001 to 2000.
-  // Keep field numbers different and within that range.
-  optional AmazonPageLoadMetric amazon_page_load_metric = 1202;
-}
diff --git a/crossbench/probes/trace_processor/metrics/protos/cnn_page_load_metric.proto b/crossbench/probes/trace_processor/metrics/protos/cnn_page_load_metric.proto
deleted file mode 100644
index 6459aa7..0000000
--- a/crossbench/probes/trace_processor/metrics/protos/cnn_page_load_metric.proto
+++ /dev/null
@@ -1,15 +0,0 @@
-syntax = "proto2";
-
-package perfetto.protos;
-
-import "protos/perfetto/metrics/metrics.proto";
-
-message CNNPageLoadMetric {
-  optional double text_shown_ms = 1;
-}
-
-extend TraceMetrics {
-  // The field number range reserved for Chrome metrics is 1001 to 2000.
-  // Keep field numbers different and within that range.
-  optional CNNPageLoadMetric cnn_page_load_metric = 1203;
-}
diff --git a/crossbench/probes/trace_processor/metrics/protos/dummy.proto b/crossbench/probes/trace_processor/metrics/protos/dummy.proto
deleted file mode 100644
index b942ec5..0000000
--- a/crossbench/probes/trace_processor/metrics/protos/dummy.proto
+++ /dev/null
@@ -1,3 +0,0 @@
-// TODO(carlscab): Add something
-
-syntax = "proto2";
\ No newline at end of file
diff --git a/crossbench/probes/trace_processor/metrics/protos/globo_page_load_metric.proto b/crossbench/probes/trace_processor/metrics/protos/globo_page_load_metric.proto
deleted file mode 100644
index be01b3f..0000000
--- a/crossbench/probes/trace_processor/metrics/protos/globo_page_load_metric.proto
+++ /dev/null
@@ -1,15 +0,0 @@
-syntax = "proto2";
-
-package perfetto.protos;
-
-import "protos/perfetto/metrics/metrics.proto";
-
-message GloboPageLoadMetric {
-  optional double cookie_banner_gone_ms = 1;
-}
-
-extend TraceMetrics {
-  // The field number range reserved for Chrome metrics is 1001 to 2000.
-  // Keep field numbers different and within that range.
-  optional GloboPageLoadMetric globo_page_load_metric = 1204;
-}
diff --git a/crossbench/probes/trace_processor/metrics/protos/lcp_metric.proto b/crossbench/probes/trace_processor/metrics/protos/lcp_metric.proto
deleted file mode 100644
index 9ed4fcf..0000000
--- a/crossbench/probes/trace_processor/metrics/protos/lcp_metric.proto
+++ /dev/null
@@ -1,15 +0,0 @@
-syntax = "proto2";
-
-package perfetto.protos;
-
-import "protos/perfetto/metrics/metrics.proto";
-
-message LCPMetric {
-  optional double lcp_ms = 1;
-}
-
-extend TraceMetrics {
-  // The field number range reserved for Chrome metrics is 1001 to 2000.
-  // Keep field numbers different and within that range.
-  optional LCPMetric lcp_metric = 1201;
-}
diff --git a/crossbench/probes/trace_processor/metrics/protos/wikipedia_page_load_metric.proto b/crossbench/probes/trace_processor/metrics/protos/wikipedia_page_load_metric.proto
deleted file mode 100644
index aaabe55..0000000
--- a/crossbench/probes/trace_processor/metrics/protos/wikipedia_page_load_metric.proto
+++ /dev/null
@@ -1,15 +0,0 @@
-syntax = "proto2";
-
-package perfetto.protos;
-
-import "protos/perfetto/metrics/metrics.proto";
-
-message WikipediaPageLoadMetric {
-  optional double last_important_event_ms = 1;
-}
-
-extend TraceMetrics {
-  // The field number range reserved for Chrome metrics is 1001 to 2000.
-  // Keep field numbers different and within that range.
-  optional WikipediaPageLoadMetric wikipedia_page_load_metric = 1205;
-}
diff --git a/crossbench/probes/trace_processor/metrics/protos/youtube_page_load_metric.proto b/crossbench/probes/trace_processor/metrics/protos/youtube_page_load_metric.proto
deleted file mode 100644
index f187ebe..0000000
--- a/crossbench/probes/trace_processor/metrics/protos/youtube_page_load_metric.proto
+++ /dev/null
@@ -1,15 +0,0 @@
-syntax = "proto2";
-
-package perfetto.protos;
-
-import "protos/perfetto/metrics/metrics.proto";
-
-message YoutubePageLoadMetric {
-  optional double cookie_banner_gone_ms = 1;
-}
-
-extend TraceMetrics {
-  // The field number range reserved for Chrome metrics is 1001 to 2000.
-  // Keep field numbers different and within that range.
-  optional YoutubePageLoadMetric youtube_page_load_metric = 1206;
-}
diff --git a/crossbench/probes/trace_processor/metrics/sql/amazon_page_load_metric.sql b/crossbench/probes/trace_processor/metrics/sql/amazon_page_load_metric.sql
deleted file mode 100644
index 341b160..0000000
--- a/crossbench/probes/trace_processor/metrics/sql/amazon_page_load_metric.sql
+++ /dev/null
@@ -1,21 +0,0 @@
--- This metric returns the time it takes for the "main" JS script to finish the
--- execution - this is when the page becomes interactive.
-SELECT IMPORT('ext.navigation_start');
-
-DROP VIEW IF EXISTS amazon_page_load_metric_output;
-
-CREATE PERFETTO VIEW amazon_page_load_metric_output AS
-SELECT AmazonPageLoadMetric(
-  'js_ready_ms', (
-      WITH
-        js_ready AS (
-          SELECT MAX(ts + dur) AS js_ready
-          FROM slice
-          WHERE
-            name = 'v8.run'
-            AND EXTRACT_ARG(arg_set_id, 'debug.fileName') = 'https://www.amazon.co.uk/NIVEA-Suncream-Spray-Protect-Moisture/dp/B001B0OJXM'
-        )
-      SELECT (js_ready - navigation_start) / 1e6
-      FROM navigation_start, js_ready
-  )
-);
\ No newline at end of file
diff --git a/crossbench/probes/trace_processor/metrics/sql/cnn_page_load_metric.sql b/crossbench/probes/trace_processor/metrics/sql/cnn_page_load_metric.sql
deleted file mode 100644
index e1d7bb5..0000000
--- a/crossbench/probes/trace_processor/metrics/sql/cnn_page_load_metric.sql
+++ /dev/null
@@ -1,14 +0,0 @@
--- This metric returns the time the headline text element takes to show up.
-SELECT IMPORT('ext.first_presentation_time');
-SELECT IMPORT('ext.navigation_start');
-
-DROP VIEW IF EXISTS cnn_page_load_metric_output;
-
-CREATE PERFETTO VIEW cnn_page_load_metric_output AS
-SELECT CNNPageLoadMetric(
-  'text_shown_ms', (
-      SELECT
-        (get_first_presentation_time_for_event('maincontent.created') - navigation_start) / 1e6
-      FROM navigation_start
-  )
-);
\ No newline at end of file
diff --git a/crossbench/probes/trace_processor/metrics/sql/dummy.sql b/crossbench/probes/trace_processor/metrics/sql/dummy.sql
deleted file mode 100644
index bfbf1a3..0000000
--- a/crossbench/probes/trace_processor/metrics/sql/dummy.sql
+++ /dev/null
@@ -1 +0,0 @@
--- TODO(carlscab): Add something
\ No newline at end of file
diff --git a/crossbench/probes/trace_processor/metrics/sql/globo_page_load_metric.sql b/crossbench/probes/trace_processor/metrics/sql/globo_page_load_metric.sql
deleted file mode 100644
index d694aff..0000000
--- a/crossbench/probes/trace_processor/metrics/sql/globo_page_load_metric.sql
+++ /dev/null
@@ -1,18 +0,0 @@
--- This metric returns the time the cookie banner takes to disappear.
-SELECT IMPORT('ext.navigation_start');
-
-DROP VIEW IF EXISTS globo_page_load_metric_output;
-
-CREATE PERFETTO VIEW globo_page_load_metric_output AS
-SELECT GloboPageLoadMetric(
-  'cookie_banner_gone_ms', (
-      WITH
-        cookie_banner_gone AS (
-            SELECT ts AS cookie_banner_gone
-            FROM slice
-            WHERE name = 'cookie_banner_gone'
-        )
-      SELECT (cookie_banner_gone - navigation_start) / 1e6
-      FROM navigation_start, cookie_banner_gone
-  )
-);
\ No newline at end of file
diff --git a/crossbench/probes/trace_processor/metrics/sql/lcp_metric.sql b/crossbench/probes/trace_processor/metrics/sql/lcp_metric.sql
deleted file mode 100644
index 76ff7e6..0000000
--- a/crossbench/probes/trace_processor/metrics/sql/lcp_metric.sql
+++ /dev/null
@@ -1,12 +0,0 @@
-DROP VIEW IF EXISTS lcp_metric_output;
-
-CREATE PERFETTO VIEW lcp_metric_output AS
-SELECT LCPMetric(
-  'lcp_ms', (
-      SELECT dur / 1e6
-      FROM slice
-      WHERE name = 'PageLoadMetrics.NavigationToLargestContentfulPaint'
-      ORDER BY ts
-      LIMIT 1
-  )
-);
diff --git a/crossbench/probes/trace_processor/metrics/sql/wikipedia_page_load_metric.sql b/crossbench/probes/trace_processor/metrics/sql/wikipedia_page_load_metric.sql
deleted file mode 100644
index 7dd7874..0000000
--- a/crossbench/probes/trace_processor/metrics/sql/wikipedia_page_load_metric.sql
+++ /dev/null
@@ -1,42 +0,0 @@
--- This metric returns the timestamp of the lASt important event (including
--- image paint, JS script runs etc.) since the beginning of the page load.
-SELECT IMPORT('ext.navigation_start');
-
-DROP VIEW IF EXISTS wikipedia_page_load_metric_output;
-
-CREATE PERFETTO VIEW wikipedia_page_load_metric_output AS
-SELECT WikipediaPageLoadMetric(
-  'last_important_event_ms', (
-     WITH
-        script_run AS (
-            SELECT ts + dur AS script_run
-            FROM slice
-            WHERE
-                name = 'v8.run'
-                AND EXTRACT_ARG(arg_set_id, 'debug.fileName') glob '*ext.cx.entrypoints.languagesearcher.init*'
-        ),
-        img_load AS (
-            SELECT ts
-            FROM slice
-            WHERE
-                name = 'PaintImage'
-                AND EXTRACT_ARG(arg_set_id, 'debug.data.url') glob '*Taylor_Swift_at_the_2023_MTV_Video_Music_Awards*'
-        ),
-        img_next_af AS (
-            SELECT id
-            FROM slice, img_load
-            WHERE
-                name = 'AnimationFrame'
-                AND slice.ts > img_load.ts
-            order by slice.ts
-            LIMIT 1
-        ),
-        img_presentation AS (
-            SELECT ts AS img_presentation
-            FROM img_next_af, DIRECTLY_CONNECTED_FLOW(img_next_af.id) AS flow, slice
-            WHERE slice.id = flow.slice_in
-        )
-        SELECT (MAX(img_presentation, script_run) - navigation_start) / 1e6
-        FROM navigation_start, img_presentation, script_run
-    )
-);
\ No newline at end of file
diff --git a/crossbench/probes/trace_processor/metrics/sql/youtube_page_load_metric.sql b/crossbench/probes/trace_processor/metrics/sql/youtube_page_load_metric.sql
deleted file mode 100644
index 5ccca5f..0000000
--- a/crossbench/probes/trace_processor/metrics/sql/youtube_page_load_metric.sql
+++ /dev/null
@@ -1,14 +0,0 @@
--- This metric returns the time the cookie banner takes to disappear.
-SELECT IMPORT('ext.first_presentation_time');
-SELECT IMPORT('ext.navigation_start');
-
-DROP VIEW IF EXISTS youtube_page_load_metric_output;
-
-CREATE PERFETTO VIEW youtube_page_load_metric_output AS
-SELECT YoutubePageLoadMetric(
-  'cookie_banner_gone_ms', (
-      SELECT
-        (get_first_presentation_time_for_event('cookie_banner_gone') - navigation_start) / 1e6
-      FROM navigation_start
-  )
-);
\ No newline at end of file
diff --git a/crossbench/probes/trace_processor/modules/ext/first_presentation_time.sql b/crossbench/probes/trace_processor/modules/ext/first_presentation_time.sql
index 1589c6f..64e2bcf 100644
--- a/crossbench/probes/trace_processor/modules/ext/first_presentation_time.sql
+++ b/crossbench/probes/trace_processor/modules/ext/first_presentation_time.sql
@@ -5,6 +5,29 @@
 --   * devtools.timeline
 --   * disabled-by-default-devtools.timeline
 --   * v8
+CREATE OR REPLACE PERFETTO FUNCTION get_next_presentation_time(ts INT)
+RETURNS INT
+AS
+WITH
+  candidate_presentation_time AS (
+    SELECT a.ts + a.dur AS ts
+    FROM slice s, ancestor_slice(s.id) a
+    WHERE
+      s.name = 'Commit'
+      AND a.name = 'PipelineReporter'
+      AND s.depth - 1 = a.depth
+      AND s.ts > $ts
+    ORDER BY s.ts
+    LIMIT 1
+  )
+SELECT ts
+FROM slice
+WHERE
+  name = 'Display::FrameDisplayed'
+  AND ts >= (SELECT ts FROM candidate_presentation_time)
+ORDER BY ts
+LIMIT 1;
+
 CREATE OR REPLACE PERFETTO FUNCTION get_first_presentation_time_for_event(
   name STRING)
 RETURNS INT
@@ -16,22 +39,6 @@
     WHERE name = $name AND cat = 'blink.user_timing'
     ORDER BY ts
     LIMIT 1
-  ),
-  candidate_presentation_time AS (
-    SELECT a.ts + a.dur AS ts
-    FROM slice s, ancestor_slice(s.id) a
-    WHERE
-      s.name = 'Commit'
-      AND a.name = 'PipelineReporter'
-      AND s.depth - 1 = a.depth
-      AND s.ts > (SELECT ts FROM event)
-    ORDER BY s.ts
-    LIMIT 1
   )
-SELECT ts
-FROM slice
-WHERE
-  name = 'Display::FrameDisplayed'
-  AND ts >= (SELECT ts FROM candidate_presentation_time)
-ORDER BY ts
-LIMIT 1;
+SELECT get_next_presentation_time(ts)
+FROM event;
diff --git a/crossbench/probes/trace_processor/queries/loading/amazon_page_load_metric.sql b/crossbench/probes/trace_processor/queries/loading/amazon_page_load_metric.sql
new file mode 100644
index 0000000..4fec12b
--- /dev/null
+++ b/crossbench/probes/trace_processor/queries/loading/amazon_page_load_metric.sql
@@ -0,0 +1,16 @@
+-- This metric returns the time it takes for the "main" JS script to finish the
+-- execution - this is when the page becomes interactive.
+SELECT IMPORT('ext.first_presentation_time');
+SELECT IMPORT('ext.navigation_start');
+
+WITH
+  js_ready AS (
+    SELECT MAX(ts) AS js_ready
+    FROM slice
+    WHERE
+      name = 'v8.run'
+      AND EXTRACT_ARG(arg_set_id, 'debug.fileName') = 'https://www.amazon.co.uk/NIVEA-Suncream-Spray-Protect-Moisture/dp/B001B0OJXM'
+  )
+SELECT (get_next_presentation_time(js_ready) - navigation_start) / 1e6 AS js_ready_ms
+FROM navigation_start, js_ready;
+
diff --git a/crossbench/probes/trace_processor/queries/loading/cnn_page_load_metric.sql b/crossbench/probes/trace_processor/queries/loading/cnn_page_load_metric.sql
new file mode 100644
index 0000000..23513f6
--- /dev/null
+++ b/crossbench/probes/trace_processor/queries/loading/cnn_page_load_metric.sql
@@ -0,0 +1,9 @@
+-- This metric returns the time the headline text element takes to show up.
+SELECT IMPORT('ext.first_presentation_time');
+SELECT IMPORT('ext.navigation_start');
+
+SELECT
+  (get_first_presentation_time_for_event('maincontent.created')
+      - navigation_start) / 1e6 AS text_shown_ms
+FROM navigation_start;
+
diff --git a/crossbench/probes/trace_processor/queries/loading/cpu.sql b/crossbench/probes/trace_processor/queries/loading/experimental/cpu.sql
similarity index 100%
rename from crossbench/probes/trace_processor/queries/loading/cpu.sql
rename to crossbench/probes/trace_processor/queries/loading/experimental/cpu.sql
diff --git a/crossbench/probes/trace_processor/queries/loading/dom.sql b/crossbench/probes/trace_processor/queries/loading/experimental/dom.sql
similarity index 100%
rename from crossbench/probes/trace_processor/queries/loading/dom.sql
rename to crossbench/probes/trace_processor/queries/loading/experimental/dom.sql
diff --git a/crossbench/probes/trace_processor/queries/loading/interaction_latency.sql b/crossbench/probes/trace_processor/queries/loading/experimental/interaction_latency.sql
similarity index 100%
rename from crossbench/probes/trace_processor/queries/loading/interaction_latency.sql
rename to crossbench/probes/trace_processor/queries/loading/experimental/interaction_latency.sql
diff --git a/crossbench/probes/trace_processor/queries/loading/mojo.sql b/crossbench/probes/trace_processor/queries/loading/experimental/mojo.sql
similarity index 100%
rename from crossbench/probes/trace_processor/queries/loading/mojo.sql
rename to crossbench/probes/trace_processor/queries/loading/experimental/mojo.sql
diff --git a/crossbench/probes/trace_processor/queries/loading/resources.sql b/crossbench/probes/trace_processor/queries/loading/experimental/resources.sql
similarity index 100%
rename from crossbench/probes/trace_processor/queries/loading/resources.sql
rename to crossbench/probes/trace_processor/queries/loading/experimental/resources.sql
diff --git a/crossbench/probes/trace_processor/queries/loading/sequence_manager.sql b/crossbench/probes/trace_processor/queries/loading/experimental/sequence_manager.sql
similarity index 100%
rename from crossbench/probes/trace_processor/queries/loading/sequence_manager.sql
rename to crossbench/probes/trace_processor/queries/loading/experimental/sequence_manager.sql
diff --git a/crossbench/probes/trace_processor/queries/loading/tlp.sql b/crossbench/probes/trace_processor/queries/loading/experimental/tlp.sql
similarity index 100%
rename from crossbench/probes/trace_processor/queries/loading/tlp.sql
rename to crossbench/probes/trace_processor/queries/loading/experimental/tlp.sql
diff --git a/crossbench/probes/trace_processor/queries/loading/v8.sql b/crossbench/probes/trace_processor/queries/loading/experimental/v8.sql
similarity index 100%
rename from crossbench/probes/trace_processor/queries/loading/v8.sql
rename to crossbench/probes/trace_processor/queries/loading/experimental/v8.sql
diff --git a/crossbench/probes/trace_processor/queries/loading/v8_rcs.sql b/crossbench/probes/trace_processor/queries/loading/experimental/v8_rcs.sql
similarity index 100%
rename from crossbench/probes/trace_processor/queries/loading/v8_rcs.sql
rename to crossbench/probes/trace_processor/queries/loading/experimental/v8_rcs.sql
diff --git a/crossbench/probes/trace_processor/queries/loading/web_features.sql b/crossbench/probes/trace_processor/queries/loading/experimental/web_features.sql
similarity index 100%
rename from crossbench/probes/trace_processor/queries/loading/web_features.sql
rename to crossbench/probes/trace_processor/queries/loading/experimental/web_features.sql
diff --git a/crossbench/probes/trace_processor/queries/loading/worker.sql b/crossbench/probes/trace_processor/queries/loading/experimental/worker.sql
similarity index 100%
rename from crossbench/probes/trace_processor/queries/loading/worker.sql
rename to crossbench/probes/trace_processor/queries/loading/experimental/worker.sql
diff --git a/crossbench/probes/trace_processor/queries/loading/globo_page_load_metric.sql b/crossbench/probes/trace_processor/queries/loading/globo_page_load_metric.sql
new file mode 100644
index 0000000..504cac2
--- /dev/null
+++ b/crossbench/probes/trace_processor/queries/loading/globo_page_load_metric.sql
@@ -0,0 +1,9 @@
+-- This metric returns the time the cookie banner takes to disappear.
+SELECT IMPORT('ext.first_presentation_time');
+SELECT IMPORT('ext.navigation_start');
+
+SELECT
+  (get_first_presentation_time_for_event('cookie_banner_gone')
+      - navigation_start) / 1e6 AS cookie_banner_gone_ms
+FROM navigation_start;
+
diff --git a/crossbench/probes/trace_processor/queries/loading/lcp_metric.sql b/crossbench/probes/trace_processor/queries/loading/lcp_metric.sql
new file mode 100644
index 0000000..0a64532
--- /dev/null
+++ b/crossbench/probes/trace_processor/queries/loading/lcp_metric.sql
@@ -0,0 +1,6 @@
+SELECT dur / 1e6 AS lcp_ms
+FROM slice
+WHERE name = 'PageLoadMetrics.NavigationToLargestContentfulPaint'
+ORDER BY ts
+LIMIT 1;
+
diff --git a/crossbench/probes/trace_processor/queries/speedometer_cpu_time.sql b/crossbench/probes/trace_processor/queries/loading/speedometer_cpu_time.sql
similarity index 100%
rename from crossbench/probes/trace_processor/queries/speedometer_cpu_time.sql
rename to crossbench/probes/trace_processor/queries/loading/speedometer_cpu_time.sql
diff --git a/crossbench/probes/trace_processor/queries/loading/wikipedia_page_load_metric.sql b/crossbench/probes/trace_processor/queries/loading/wikipedia_page_load_metric.sql
new file mode 100644
index 0000000..4c50e66
--- /dev/null
+++ b/crossbench/probes/trace_processor/queries/loading/wikipedia_page_load_metric.sql
@@ -0,0 +1,36 @@
+-- This metric returns the timestamp of the last important event (including
+-- image paint, JS script runs etc.) since the beginning of the page load.
+SELECT IMPORT('ext.navigation_start');
+
+WITH
+  script_run AS (
+      SELECT ts + dur AS script_run
+      FROM slice
+      WHERE
+          name = 'v8.run'
+          AND EXTRACT_ARG(arg_set_id, 'debug.fileName') GLOB '*ext.cx.entrypoints.languagesearcher.init*'
+  ),
+  img_load AS (
+      SELECT ts
+      FROM slice
+      WHERE
+          name = 'PaintImage'
+          AND EXTRACT_ARG(arg_set_id, 'debug.data.url') GLOB '*Taylor_Swift_at_the_2023_MTV_Video_Music_Awards*'
+  ),
+  img_next_af AS (
+      SELECT id
+      FROM slice, img_load
+      WHERE
+          name = 'AnimationFrame'
+          AND slice.ts > img_load.ts
+      order by slice.ts
+      LIMIT 1
+  ),
+  img_presentation AS (
+      SELECT ts AS img_presentation
+      FROM img_next_af, DIRECTLY_CONNECTED_FLOW(img_next_af.id) AS flow, slice
+      WHERE slice.id = flow.slice_in
+  )
+SELECT (MAX(img_presentation, script_run) - navigation_start) / 1e6 AS last_important_event_ms
+FROM navigation_start, img_presentation, script_run;
+
diff --git a/crossbench/probes/trace_processor/queries/loading/youtube_page_load_metric.sql b/crossbench/probes/trace_processor/queries/loading/youtube_page_load_metric.sql
new file mode 100644
index 0000000..923704d
--- /dev/null
+++ b/crossbench/probes/trace_processor/queries/loading/youtube_page_load_metric.sql
@@ -0,0 +1,8 @@
+-- This metric returns the time the cookie banner takes to disappear.
+SELECT IMPORT('ext.first_presentation_time');
+SELECT IMPORT('ext.navigation_start');
+
+SELECT
+  (get_first_presentation_time_for_event('cookie_banner_gone') - navigation_start) / 1e6 AS cookie_banner_gone_ms
+FROM navigation_start;
+