Skip to content

Commit

Permalink
Merge pull request #1220 from glimmerjs/bugfix/absorb-breakage-in-ben…
Browse files Browse the repository at this point in the history
…chmark-env

[BUGFIX] Absorb breakage in benchmark-env instead of benchmark
  • Loading branch information
Chris Garrett authored Dec 2, 2020
2 parents 5787762 + 40ea47f commit 3f4c054
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 18 deletions.
6 changes: 0 additions & 6 deletions benchmark/benchmarks/krausest/lib/components/Application.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
import { templateFactory } from '@glimmer/opcode-compiler';
import { setComponentTemplate } from '@glimmer/manager';
import ApplicationTemplate from './Application.hbs';

export default class Application {
constructor(args) {
this.args = args;
Expand All @@ -21,6 +17,4 @@ export default class Application {
}
}

setComponentTemplate(templateFactory(ApplicationTemplate), Application);

/** @typedef {import('../utils/data').Item} Item */
6 changes: 0 additions & 6 deletions benchmark/benchmarks/krausest/lib/components/Row.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
import { templateFactory } from '@glimmer/opcode-compiler';
import { setComponentTemplate } from '@glimmer/manager';
import RowTemplate from './Row.hbs';

export default class Row {
constructor(args) {
this.args = args;
Expand All @@ -12,5 +8,3 @@ export default class Row {
};
}
}

setComponentTemplate(templateFactory(RowTemplate), Row);
12 changes: 9 additions & 3 deletions packages/@glimmer/benchmark-env/src/create-benchmark.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { TemplateOnlyComponentManager } from '@glimmer/runtime';
import { getComponentTemplate } from '@glimmer/manager';
import { getComponentTemplate, setComponentTemplate } from '@glimmer/manager';
import { Benchmark } from './interfaces';
import createRegistry from './benchmark/create-registry';
import onModifier from './benchmark/on-modifier';
import ifHelper from './benchmark/if-helper';
import basicComponentManager from './benchmark/basic-component-manager';
import { templateFactory } from '@glimmer/opcode-compiler';

class TemplateOnlyComponentManagerWithGetComponentTemplate extends TemplateOnlyComponentManager {
getStaticLayout(definition: object) {
Expand All @@ -19,10 +20,15 @@ export default function createBenchmark(): Benchmark {
registry.registerModifier('on', null, onModifier);
registry.registerHelper('if', ifHelper);
return {
templateOnlyComponent: (name) => {
templateOnlyComponent: (name, template) => {
let definition = {};
setComponentTemplate(templateFactory(template), definition);

registry.registerComponent(name, null, TEMPLATE_ONLY_COMPONENT_MANAGER);
},
basicComponent: (name, _template, component) => {
basicComponent: (name, template, component) => {
setComponentTemplate(templateFactory(template), component);

registry.registerComponent(name, component, basicComponentManager);
},
render: registry.render,
Expand Down
6 changes: 3 additions & 3 deletions packages/@glimmer/benchmark-env/src/interfaces.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Dict, Template } from '@glimmer/interfaces';
import { Dict, SerializedTemplateWithLazyBlock } from '@glimmer/interfaces';
import { SimpleElement } from '@simple-dom/interface';

/**
Expand All @@ -17,7 +17,7 @@ export interface Benchmark {
* @param name
* @param template
*/
templateOnlyComponent(name: string): void;
templateOnlyComponent(name: string, template: SerializedTemplateWithLazyBlock): void;

/**
* Register a basic component
Expand All @@ -27,7 +27,7 @@ export interface Benchmark {
*/
basicComponent<TComponent extends object = object>(
name: string,
_template: Template,
template: SerializedTemplateWithLazyBlock,
component: new (args: ComponentArgs) => TComponent
): void;

Expand Down

0 comments on commit 3f4c054

Please sign in to comment.