Welcome to mirror list, hosted at ThFree Co, Russian Federation.

renderList.js « benchmarks « wwwroot « Microsoft.AspNetCore.Blazor.E2EPerformance « wasm - github.com/mono/illinker-test-assets.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 68bf32d747c10f020ba3dd32f029597a3a6e3689 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import { group, benchmark, setup, teardown } from './lib/minibench/minibench.js';
import { BlazorApp } from './util/BlazorApp.js';
import { receiveEvent } from './util/BenchmarkEvents.js';
import { setInputValue } from './util/DOM.js';

group('Rendering list', () => {
  let app;

  setup(async () => {
    app = new BlazorApp();
    await app.start();
    app.navigateTo('renderList');
  });

  teardown(() => {
    app.dispose();
  });

  benchmark('Render 10 items', () => measureRenderList(app, 10));
  benchmark('Render 100 items', () => measureRenderList(app, 100));
  benchmark('Render 1000 items', () => measureRenderList(app, 1000));

});

async function measureRenderList(app, numItems) {
  const appDocument = app.window.document;
  const numItemsTextbox = appDocument.querySelector('#num-items');
  setInputValue(numItemsTextbox, numItems.toString());

  let nextRenderCompletion = receiveEvent('Finished rendering list');
  appDocument.querySelector('#hide-list').click();
  await nextRenderCompletion;

  if (appDocument.querySelectorAll('tbody tr').length !== 0) {
    throw new Error('Wrong number of items rendered');
  }

  nextRenderCompletion = receiveEvent('Finished rendering list');
  appDocument.querySelector('#show-list').click();
  await nextRenderCompletion;

  if (appDocument.querySelectorAll('tbody tr').length !== numItems) {
    throw new Error('Wrong number of items rendered');
  }
}