MCPcopy
hub / github.com/webpack/webpack / getBaselineRevs

Function getBaselineRevs

test/BenchmarkTestCases.benchmark.mjs:122–161  ·  view source on GitHub ↗

* @returns {Promise<{ name: string, rev?: string }[]>} baseline revs

()

Source from the content-addressed store, hash-verified

120 * @returns {Promise<{ name: string, rev?: string }[]>} baseline revs
121 */
122async function getBaselineRevs() {
123 if (LAST_COMMIT) {
124 return [
125 {
126 name: "HEAD"
127 }
128 ];
129 }
130
131 const resultParents = await git.raw([
132 "rev-list",
133 "--parents",
134 "-n",
135 "1",
136 "HEAD"
137 ]);
138 const revList =
139 /** @type {[string, string, string, string | undefined] | null} */
140 (REV_LIST_REGEXP.exec(resultParents));
141
142 if (!revList) throw new Error("Invalid result from git rev-list");
143
144 const head = await getHead(revList);
145 const base = await getBase(head, revList);
146
147 if (!head || !base) {
148 throw new Error("No baseline found");
149 }
150
151 return [
152 {
153 name: "HEAD",
154 rev: head
155 },
156 {
157 name: "BASE",
158 rev: base
159 }
160 ];
161}
162
163/**
164 * @param {number} n number of runs

Calls 3

getHeadFunction · 0.85
getBaseFunction · 0.85
execMethod · 0.80

Tested by

no test coverage detected