Skip to content

Commit

Permalink
fix: reporter performance
Browse files Browse the repository at this point in the history
Signed-off-by: mbwhite <whitemat@uk.ibm.com>
  • Loading branch information
mbwhite committed Apr 4, 2024
1 parent fb788b8 commit 89da836
Show file tree
Hide file tree
Showing 8 changed files with 104,529 additions and 25 deletions.
6 changes: 3 additions & 3 deletions example-task.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: Task-without-params
name: Task_without-params
spec:
params: []
steps:
- name: ls-build-sources
- name: ls-build_sources
command: ["ls", "-ltr", "/workspace/source/$(params.contextDir)"]
image: busybox
workingDir: /workspace/source/$(params.contextDir)
workspaces:
- description: The git repo will be cloned onto the volume backing this workspace
name: source
name: source
20 changes: 0 additions & 20 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"scripts": {
"clean": "rimraf dist",
"lint": "eslint --ext ts src",
"test": "node --experimental-vm-modules --no-warnings node_modules/jest/bin/jest.js ",
"test": "node --experimental-vm-modules --no-warnings node_modules/jest/bin/jest.js",
"test:debug": "node --experimental-vm-modules --no-warnings --inspect-brk node_modules/jest/bin/jest.js --runInBand",
"format": "prettier --write \"{src,test}/**/*.ts\"",
"prebuild": "npm run format && npm run clean && npm run lint",
"build": "tsc --pretty",
Expand Down
94 changes: 94 additions & 0 deletions src/perf/node.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
import { KeyComparator } from './tree.js';

export class IndexRange implements KeyComparator {
public start: number;
public end: number;

constructor(start: number, end?: number) {
this.start = start;
this.end = end ? end : start;
}
public isQuery() {
return this.start == this.end;
}

public toString(): string {
return `[${this.start}-${this.end}]`;
}

public compare(other: IndexRange): number {
if (this.isQuery()) {
if (this.start >= other.start && this.start <= other.end) {
return 0;
}
}

if (other.isQuery()) {
if (other.start >= this.start && other.start <= this.end) {
return 0;
}
}

if (this.start > other.end) {
// goes to the right as larger
return 1;
} else if (this.end <= other.start) {
return -1;
}

// which should in theory never happen
return 0;
}

isEqual(key: IndexRange): boolean {
return this.compare(key) === 0;
}

isGreater(key: IndexRange): boolean {
return this.compare(key) > 0;
}

isLesser(key: IndexRange): boolean {
return this.compare(key) < 0;
}
}

export class Result {
public lineNumber: number;
public columnOffset: number;

constructor(lineNumber: number, columnOffset: number) {
this.lineNumber = lineNumber;
this.columnOffset = columnOffset;
}

public isEqual(r: Result): boolean {
return this.lineNumber == r.lineNumber && this.columnOffset == r.columnOffset;
}

public toString(): string {
return `Ln ${this.lineNumber} Col ${this.columnOffset}`;
}
}

export class LineNode {
public indexRange: IndexRange;
public value: number;

constructor(indexRange, value: number) {
this.indexRange = indexRange;
this.value = value;
}

public isQuery() {
return this.indexRange.isQuery();
}

public compare(other: LineNode): number {
return this.indexRange.compare(other.indexRange);
}

public toString(): string {
return `${this.indexRange} @ ${this.value}`;
}
}
Loading

0 comments on commit 89da836

Please sign in to comment.