Skip to content

Commit

Permalink
Rename measurement 'kind' to 'mode'
Browse files Browse the repository at this point in the history
  • Loading branch information
aomarks committed Jul 23, 2020
1 parent 0448e65 commit 9d54ad3
Show file tree
Hide file tree
Showing 15 changed files with 71 additions and 71 deletions.
6 changes: 3 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ project adheres to [Semantic Versioning](http://semver.org/).
"benchmarks": [
{
"measurement": {
"kind": "performance",
"mode": "performance",
"entryName": "foo"
}
}
Expand All @@ -32,12 +32,12 @@ project adheres to [Semantic Versioning](http://semver.org/).
"benchmarks": [
{
"measurement": {
"kind": "callback"
"mode": "callback"
}
},
{
"measurement": {
"kind": "expression",
"mode": "expression",
"expression": "window.tachometerResult"
}
}
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ confidence in them.
## Measurement modes
Tachometer supports four kinds of time interval measurements, controlled with
Tachometer supports four modes of time interval measurements, controlled with
the `measurement` config file property, or the `--measure` flag.
If `measurement` is an array, then all of the given measurements will be
Expand Down Expand Up @@ -111,7 +111,7 @@ And in your config file:
"benchmarks": [
{
"measurement": {
"kind": "performance",
"mode": "performance",
"entryName": "foo"
}
}
Expand Down
12 changes: 6 additions & 6 deletions config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
"CallbackMeasurement": {
"additionalProperties": false,
"properties": {
"kind": {
"mode": {
"enum": [
"callback"
],
"type": "string"
}
},
"required": [
"kind"
"mode"
],
"type": "object"
},
Expand Down Expand Up @@ -207,7 +207,7 @@
"expression": {
"type": "string"
},
"kind": {
"mode": {
"enum": [
"expression"
],
Expand All @@ -216,7 +216,7 @@
},
"required": [
"expression",
"kind"
"mode"
],
"type": "object"
},
Expand Down Expand Up @@ -307,7 +307,7 @@
"entryName": {
"type": "string"
},
"kind": {
"mode": {
"enum": [
"performance"
],
Expand All @@ -316,7 +316,7 @@
},
"required": [
"entryName",
"kind"
"mode"
],
"type": "object"
},
Expand Down
2 changes: 1 addition & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export async function makeConfig(opts: Opts): Promise<Config> {

for (const spec of config.benchmarks) {
for (const measurement of spec.measurement) {
if (measurement.kind === 'performance' &&
if (measurement.mode === 'performance' &&
measurement.entryName === 'first-contentful-paint' &&
!fcpBrowsers.has(spec.browser.name)) {
throw new Error(
Expand Down
6 changes: 3 additions & 3 deletions src/configfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -343,16 +343,16 @@ async function parseBenchmark(benchmark: ConfigFileBenchmark, root: string):

if (benchmark.measurement === 'callback') {
spec.measurement = [{
kind: 'callback',
mode: 'callback',
}];
} else if (benchmark.measurement === 'fcp') {
spec.measurement = [{
kind: 'performance',
mode: 'performance',
entryName: 'first-contentful-paint',
}];
} else if (benchmark.measurement === 'global') {
spec.measurement = [{
kind: 'expression',
mode: 'expression',
expression:
benchmark.measurementExpression || defaults.measurementExpression,
}];
Expand Down
4 changes: 2 additions & 2 deletions src/defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ export const measurementExpression = 'window.tachometerResult';
export function measurement(url: LocalUrl|RemoteUrl): Measurement {
if (url.kind === 'remote') {
return {
kind: 'performance',
mode: 'performance',
entryName: 'first-contentful-paint',
};
}
return {kind: 'callback'};
return {mode: 'callback'};
}
4 changes: 2 additions & 2 deletions src/measure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export async function measure(
driver: webdriver.WebDriver,
measurement: Measurement,
server: Server|undefined): Promise<number|undefined> {
switch (measurement.kind) {
switch (measurement.mode) {
case 'callback':
if (server === undefined) {
throw new Error('Internal error: no server for spec');
Expand Down Expand Up @@ -125,7 +125,7 @@ function escapeStringLiteral(unescaped: string): string {
* where there are multiple measurements on the same page.
*/
export function measurementName(measurement: Measurement): string {
switch (measurement.kind) {
switch (measurement.mode) {
case 'callback':
return 'callback';
case 'expression':
Expand Down
6 changes: 3 additions & 3 deletions src/specs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,16 @@ export async function specsFromOpts(opts: Opts): Promise<BenchmarkSpec[]> {
let measurement: Measurement|undefined;
if (opts.measure === 'callback') {
measurement = {
kind: 'callback',
mode: 'callback',
};
} else if (opts.measure === 'fcp') {
measurement = {
kind: 'performance',
mode: 'performance',
entryName: 'first-contentful-paint',
};
} else if (opts.measure === 'global') {
measurement = {
kind: 'expression',
mode: 'expression',
expression:
opts['measurement-expression'] || defaults.measurementExpression,
};
Expand Down
8 changes: 4 additions & 4 deletions src/test/config_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ suite('makeConfig', function() {
},
},
measurement: [{
kind: 'callback',
mode: 'callback',
}],
name: 'random-global.html',
url: {
Expand Down Expand Up @@ -104,7 +104,7 @@ suite('makeConfig', function() {
},
},
measurement: [{
kind: 'callback',
mode: 'callback',
}],
// TODO(aomarks) Why does this have a forward-slash?
name: '/random-global.html',
Expand Down Expand Up @@ -147,7 +147,7 @@ suite('makeConfig', function() {
},
},
measurement: [{
kind: 'callback',
mode: 'callback',
}],
// TODO(aomarks) Why does this have a forward-slash?
name: '/random-global.html',
Expand Down Expand Up @@ -197,7 +197,7 @@ suite('makeConfig', function() {
},
},
measurement: [{
kind: 'callback',
mode: 'callback',
}],
// TODO(aomarks) Why does this have a forward-slash?
name: '/random-global.html',
Expand Down
Loading

0 comments on commit 9d54ad3

Please sign in to comment.