- times
- start up time: the time from "the command is executed" to the time "load event is triggered in browser".
- root HMR time: the time from "the root file is changed" to the time "that file is executed in browser".
- leaf HMR time: the time from "the leaf file is changed" to the time "that file is executed in browser".
- cold/hot start
- cold start: the dependency optimization cache is deleted before each run
- hot start: the dependency optimization cache exists by each run
This file contains 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
oxc_napi: __napi_register__OxcError_struct_0 | |
oxc_napi: __napi_register__ErrorLabel_struct_1 | |
oxc_napi: __napi_register__Severity_2 | |
oxc_sourcemap: __napi_register__SourceMap_struct_0 | |
oxc_transform_napi: __napi_register__IsolatedDeclarationsResult_struct_0 | |
oxc_transform_napi: __napi_register__IsolatedDeclarationsOptions_struct_1 | |
oxc_transform_napi: __napi_register__isolated_declaration_2 | |
oxc_transform_napi: __napi_register__TransformResult_struct_3 | |
oxc_transform_napi: __napi_register__TransformOptions_struct_4 | |
oxc_transform_napi: __napi_register__CompilerAssumptions_struct_5 |
This file contains 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
import { Bench } from 'tinybench' | |
import { original_stringify_string, new_stringify_string } from './func.js' | |
const inputs = ['longg', 'long\n', '""\n""', '<foo>', '<<<<<'] | |
const repeats = [2, 20, 200, 2000] | |
const bench = new Bench() | |
for (const [i, input] of inputs.entries()) { | |
for (const r of repeats) { |
-
start up time: the time from "the command is executed" to the time "load event is triggered in browser".
-
root HMR time: the time from "the root file is changed" to the time "that file is executed in browser".
-
leaf HMR time: the time from "the leaf file is changed" to the time "that file is executed in browser".
-
cold start: the dependency optimization cache is deleted before each run
-
hot start: the dependency optimization cache exists by each run
This file contains 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
import { Worker } from 'worker_threads' | |
function genWorkerCode(fn) { | |
return ` | |
const doWork = ${fn.toString()} | |
const { parentPort } = require('worker_threads') | |
parentPort.on('message', async (args) => { | |
const res = await doWork(...args) | |
parentPort.postMessage(res) | |
}) |
This file contains 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
import fs from 'node:fs/promises' | |
import path from 'node:path' | |
import { appendUse } from './utils' | |
export const convert = async (p: string): Promise<string[]> => { | |
const content = await fs.readFile(p, 'utf-8') | |
let replacedContent = content.replace( | |
/\/use\/(\w+)/g, | |
(_m, p1) => `/composables/${appendUse(p1)}` |
This file contains 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
const t = typeof vi !== 'undefined' ? vi : jest | |
test('Math.random mock', () => { | |
// const original = Math.random | |
const mocked = t.fn(() => 0.1); | |
Math.random = mocked | |
// Math.random = original | |
}); |
This file contains 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
package prediction | |
import ( | |
"math/rand" | |
"testing" | |
) | |
func BenchmarkEvery(b *testing.B) { | |
howmany := 10000000 | |
out := [10000000]int{} |
This file contains 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
import java.util.*; | |
public class Solve { | |
public static void main(String[] args){ | |
Scanner sc = new Scanner(System.in); | |
int n = sc.nextInt(); | |
for(int i = 0; i < n; i++){ | |
char[] y = sc.next().toCharArray(); | |
char[] x = sc.next().toCharArray(); | |
int sum = 0; | |
sum += Character.getNumericValue(y[0]) * 2; |