-
Notifications
You must be signed in to change notification settings - Fork 160
docs(performance): Add README to the performance project #16252
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
0a8395a
docs(performance): Add README to the performance project
mddragnev b4e7a56
Merge branch '20.1.x' into mdragnev/performance-readme
ChronosSF 3e129f3
Merge branch '20.1.x' into mdragnev/performance-readme
kdinev 0686b6e
chore(*): fix a typo
mddragnev 059890f
chore(*): remove redundant backtick
mddragnev 64059de
Merge branch '20.1.x' into mdragnev/performance-readme
kdinev db0a058
Merge branch '20.1.x' into mdragnev/performance-readme
mddragnev 98a3b86
Merge branch '20.1.x' into mdragnev/performance-readme
kdinev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,111 @@ | ||
| # Ignite UI performance project | ||
|
|
||
| This project contains sample applications for the grid, tree grid, and pivot grid, with predefined data source sizes of 1,000, 100,000, and 1,000,000 records. These samples are used to measure the performance of different grid features using an internal `PerformanceService`, which is a wrapper around the browser's Performance API. | ||
|
|
||
| To run the application: | ||
|
|
||
| ```sh | ||
| npm run start:performance | ||
| ``` | ||
|
|
||
| ## Using the performance service | ||
|
|
||
| The performance service is intended to be used as a injectable service inside a component that would be measured. In order to inject it add a private property in the component: | ||
|
|
||
| ```ts | ||
| private performanceService = inject(PerformanceService); | ||
| ``` | ||
|
|
||
| This will initialize the service and also create a global `$$igcPerformance` variable that can be used for convenience. | ||
|
|
||
| ### API | ||
|
|
||
| ```ts | ||
| performanceService.setLogEnabled(true); | ||
| ``` | ||
|
|
||
| - Set whether the service should use `console.debug` to print the performance entries. Defaults to `false`. | ||
|
|
||
| ```ts | ||
| const end = performanceService.start(name); | ||
| data.sort(); | ||
| end(); | ||
| ``` | ||
|
|
||
| - Starts a performance measuring. The method returns a function that should be invoked after the code you want to measure has finished executing. This creates a `PerformanceMeasure` entry in the browser's performance timeline. | ||
|
|
||
| ```ts | ||
| const performanceMeasures: PerformanceEntryList = performanceService.getMeasures(name?); | ||
| ``` | ||
|
|
||
| - Gets list of `PerformanceMeasure` entries`. If a name is provided, it returns only the measures with that name. | ||
mddragnev marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ```ts | ||
| performanceService.clearMeasures(name?); | ||
| ``` | ||
|
|
||
| - Clears all performed measures. If a `name` is provided, it clears only the measures with that name. | ||
|
|
||
| > **Note:** The `$$igcPerformance` global object could be used as an alternative to the injected `performanceService` instance. | ||
|
|
||
| ### Reading results | ||
|
|
||
| Let's say that we want to measure the time that the grid's sorting pipeline takes to sort the data. We first go to the `IgxGridSortingPipe` and modify the code to look like this: | ||
|
|
||
| ```ts | ||
| @Pipe({ | ||
| name: 'gridSort', | ||
| standalone: true, | ||
| }) | ||
| export class IgxGridSortingPipe implements PipeTransform { | ||
| private performance = inject(PerformanceService); | ||
|
|
||
| constructor(@Inject(IGX_GRID_BASE) private grid: GridType) {} | ||
|
|
||
| public transform( | ||
| collection: any[], | ||
| sortExpressions: ISortingExpression[], | ||
| groupExpressions: IGroupingExpression[], | ||
| sorting: IGridSortingStrategy, | ||
| id: string, | ||
| pipeTrigger: number, | ||
| pinned? | ||
| ): any[] { | ||
| // This is important! | ||
| this.performance.setLogEnabled(true); | ||
| const endSorting = this.performance.start('Sorting pipe'); | ||
|
|
||
| let result: any[]; | ||
| const expressions = groupExpressions.concat(sortExpressions); | ||
| if (!expressions.length) { | ||
| result = collection; | ||
| } else { | ||
| result = DataUtil.sort( | ||
| cloneArray(collection), | ||
| expressions, | ||
| sorting, | ||
| this.grid | ||
| ); | ||
| } | ||
| this.grid.setFilteredSortedData(result, pinned); | ||
|
|
||
| // This is important! | ||
| endSorting(); | ||
|
|
||
| return result; | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| If you run a sample and sort a column, the performance service will measure the execution time of the sorting pipe. There are two ways to see the results: | ||
|
|
||
| 1. If `setLogEnabled` is called with `true` then the service will print the measurement result in the console using `console.debug`. | ||
| <img width="1720" height="863" alt="performance-console" src="https://github.com/user-attachments/assets/000d0bfd-a180-447d-ac27-2f82904e1150" /> | ||
|
|
||
| 2. The browser's DevTools Performance tab can be used for a more detailed analysis. Before triggering the action (e.g., sorting), start a new performance recording in DevTools. | ||
|
|
||
|
|
||
| https://github.com/user-attachments/assets/8aa80ead-82d0-48a4-a6d2-1c17b3d099b1 | ||
|
|
||
|
|
||
| You should look at the timings tab in the performance window in dev-tools. | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.