Skip to content
This repository was archived by the owner on Oct 16, 2024. It is now read-only.

Commit 123b45e

Browse files
committed
fixed typo
1 parent fcc6b76 commit 123b45e

File tree

10 files changed

+62
-31
lines changed

10 files changed

+62
-31
lines changed

benchmark/benchmarks/react/1000fields/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
endBenchmarkLog,
77
getCycleResult,
88
startBenchmarkLog,
9-
} from '../../../benchmarkManager';
9+
} from '../../benchmarkManager';
1010

1111
// Files to run the Benchmark on
1212
import agileCollection from './bench/agilets/collection';

benchmark/benchmarks/react/computed/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
endBenchmarkLog,
77
getCycleResult,
88
startBenchmarkLog,
9-
} from '../../../benchmarkManager';
9+
} from '../../benchmarkManager';
1010

1111
// Files to run the Benchmark on
1212
import agileAutoTracking from './bench/agilets/autoTracking';

benchmark/benchmarks/react/counter/bench/agilets.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { useAgile } from '@agile-ts/react';
66
const COUNT = createState(0);
77

88
const App = () => {
9-
const count = useAgile(COUNT, undefined);
9+
const count = useAgile(COUNT);
1010
return <h1 onClick={() => COUNT.set((state) => state + 1)}>{count}</h1>;
1111
};
1212

benchmark/benchmarks/react/counter/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
endBenchmarkLog,
77
getCycleResult,
88
startBenchmarkLog,
9-
} from '../../../benchmarkManager';
9+
} from '../../benchmarkManager';
1010

1111
// Files to run the Benchmark on
1212
import agilets from './bench/agilets';

benchmark/benchmarks/typescript/defineConfig/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
endBenchmarkLog,
66
getCycleResult,
77
startBenchmarkLog,
8-
} from '../../../benchmarkManager';
8+
} from '../../benchmarkManager';
99

1010
// Files to run the Benchmark on
1111
import * as referencer from './bench/referencer';

benchmark/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"homepage": "https://agile-ts.org/",
88
"description": "Benchmark Tests",
99
"scripts": {
10-
"test": "node -r esbuild-register run.ts",
10+
"test": "node -r esbuild-register runtime/run.ts",
1111
"test:counter": "yarn test ./benchmarks/react/counter",
1212
"test:1000fields": "yarn test ./benchmarks/react/1000fields",
1313
"test:computed": "yarn test ./benchmarks/react/computed",
Lines changed: 33 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,9 @@
1-
import dotenv from 'dotenv';
1+
import chalk from 'chalk';
22
import esbuild from 'esbuild';
33
import playwright from 'playwright';
4-
import chalk from 'chalk';
5-
6-
// Loads environment variables from the '.env' file
7-
dotenv.config();
8-
9-
// TODO implement yargs https://yargs.js.org/
4+
import fs from 'fs';
105

11-
// https://nodejs.org/docs/latest/api/process.html#process_process_argv
12-
// Extract entry (at third parameter) from the executed command
13-
// yarn run ./path/to/entry -> './path/to/entry' is extracted
14-
const entry = process.argv.slice(2)[0];
15-
const isDev =
16-
process.argv.slice(2)[1] === '--dev' || process.env.DEV === 'true';
17-
if (entry == null) {
18-
throw new Error(
19-
"No valid entry was provided! Valid entry example: 'yarn run ./benchmarks/react/counter'"
20-
);
21-
}
22-
23-
const startSpeedBench = async () => {
6+
export const startSpeedBench = async (entry: string, isDev: boolean) => {
247
console.log(chalk.blue('Starting the speed benchmark server..\n'));
258

269
// Bundle Benchmark Test Suite
@@ -116,7 +99,7 @@ const startSpeedBench = async () => {
11699
server.stop();
117100
};
118101

119-
const startBundleBench = async () => {
102+
export const startBundleBench = async (entry: string, isDev: boolean) => {
120103
const bundle = await esbuild.build({
121104
inject: ['./lodash.ts'], // https://esbuild.github.io/api/#inject
122105
entryPoints: [entry], // https://esbuild.github.io/api/#entry-points
@@ -130,12 +113,38 @@ const startBundleBench = async () => {
130113
metafile: true, // https://esbuild.github.io/api/#metafile
131114
});
132115

116+
console.log(
117+
`${chalk.blue('[i]')} ${chalk.gray(
118+
`Entry was ${chalk.green(`successfully`)} bundled`
119+
)}`
120+
);
121+
122+
if (isDev) {
123+
console.log(
124+
`${chalk.blue('[i]')} ${chalk.gray(
125+
`Development mode is ${chalk.green(`active`)}`
126+
)}`
127+
);
128+
}
129+
133130
// Extract metafile from bundle (https://esbuild.github.io/api/#metafile)
134131
const metafile = bundle.metafile;
135132

133+
// Calculate bundle file size
134+
let bundleSize = 0;
135+
bundle.outputFiles?.map((file) => {
136+
const stats = fs.statSync(file.path);
137+
const fileSizeInBytes = stats.size;
138+
const fileSizeInKilobytes = fileSizeInBytes / 1024;
139+
bundleSize += fileSizeInKilobytes;
140+
});
141+
142+
console.log(
143+
`${chalk.blue('[i]')} ${chalk.gray(
144+
`Total bundle size of the bundle is ${chalk.blueBright.bold(bundleSize)}`
145+
)}`
146+
);
147+
136148
console.log(metafile);
137149
// TODO analyze metafile
138150
};
139-
140-
// Execute the Benchmark
141-
startSpeedBench();

benchmark/runtime/run.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import dotenv from 'dotenv';
2+
import { startSpeedBench } from './benchmarkTypes';
3+
4+
// Loads environment variables from the '.env' file
5+
dotenv.config();
6+
7+
// TODO implement yargs https://yargs.js.org/
8+
9+
// https://nodejs.org/docs/latest/api/process.html#process_process_argv
10+
// Extract entry (at third parameter) from the executed command
11+
// yarn run ./path/to/entry -> './path/to/entry' is extracted
12+
const entry = process.argv.slice(2)[0];
13+
const isDev =
14+
process.argv.slice(2)[1] === '--dev' || process.env.DEV === 'true';
15+
if (entry == null) {
16+
throw new Error(
17+
"No valid entry was provided! Valid entry example: 'yarn run ./benchmarks/react/counter'"
18+
);
19+
}
20+
21+
// Execute the Benchmark
22+
startSpeedBench(entry, isDev);

packages/react/src/hooks/useAgile.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ export function useAgile<
109109
// If specified selector function and the value is of type object.
110110
// Return the selected value.
111111
// (Destroys the type of the useAgile hook,
112-
// however the type is adjusted in the useSelector hook)
112+
// however the type can be adjusted in the useSelector hook)
113113
if (config.selector && isValidObject(value, true)) {
114114
return config.selector(value);
115115
}

0 commit comments

Comments
 (0)