mirror of
https://github.com/denoland/deno.git
synced 2025-08-04 10:59:13 +00:00
feat(init): Generate main_bench.ts by default (#16786)
This commit changes "deno init" to generate "main_bench.ts" file which scaffold two example bench cases.
This commit is contained in:
parent
6794d9fe5d
commit
4eb8e875fd
3 changed files with 53 additions and 0 deletions
|
@ -40,6 +40,8 @@ pub async fn init_project(init_flags: InitFlags) -> Result<(), AnyError> {
|
|||
let main_test_ts = include_str!("./templates/main_test.ts")
|
||||
.replace("{CURRENT_STD_URL}", deno_std::CURRENT_STD_URL.as_str());
|
||||
create_file(&dir, "main_test.ts", &main_test_ts)?;
|
||||
let main_bench_ts = include_str!("./templates/main_bench.ts");
|
||||
create_file(&dir, "main_bench.ts", main_bench_ts)?;
|
||||
|
||||
create_file(&dir, "deno.jsonc", include_str!("./templates/deno.jsonc"))?;
|
||||
|
||||
|
@ -62,5 +64,8 @@ pub async fn init_project(init_flags: InitFlags) -> Result<(), AnyError> {
|
|||
info!("");
|
||||
info!(" {}", colors::gray("// Run the tests"));
|
||||
info!(" deno test");
|
||||
info!("");
|
||||
info!(" {}", colors::gray("// Run the benchmarks"));
|
||||
info!(" deno bench");
|
||||
Ok(())
|
||||
}
|
||||
|
|
9
cli/tools/init/templates/main_bench.ts
Normal file
9
cli/tools/init/templates/main_bench.ts
Normal file
|
@ -0,0 +1,9 @@
|
|||
import { add } from "./main.ts";
|
||||
|
||||
Deno.bench(function addSmall() {
|
||||
add(1, 2);
|
||||
});
|
||||
|
||||
Deno.bench(function addBig() {
|
||||
add(2 ** 32, 2 ** 32);
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue