2023-07-29 15:27:03 +03:00
|
|
|
# JS DOM Benchmark Chart
|
|
|
|
|
2023-01-24 03:07:13 +03:00
|
|
|
![image](https://user-images.githubusercontent.com/63821277/186010833-2ea36f3a-4738-4025-9b23-ac62afe74b81.png)
|
|
|
|
|
2023-07-29 15:27:03 +03:00
|
|
|
## Running the App
|
|
|
|
|
|
|
|
> **NOTE**\
|
|
|
|
> The following steps require Node.js.
|
|
|
|
> To install Node, please refer to the [download page](https://nodejs.org/en/download/)
|
|
|
|
> or the installation via your operating systems [package manager](https://nodejs.org/en/download/package-manager).
|
|
|
|
|
|
|
|
The steps below assume that your current directory path is the examples project directory.
|
|
|
|
|
|
|
|
```
|
|
|
|
cd examples/js_dom_draw_bechmark_chart
|
|
|
|
```
|
|
|
|
|
|
|
|
Execute the following commands in separate terminal instances.
|
2022-09-07 01:55:32 +03:00
|
|
|
|
2023-07-29 15:27:03 +03:00
|
|
|
Run the Benchmarks Typescript Part
|
2022-09-07 01:55:32 +03:00
|
|
|
|
2023-07-29 15:27:03 +03:00
|
|
|
```sh
|
|
|
|
npm i --prefix typescript_vanilla_typeorm
|
|
|
|
npm run start:dev --prefix typescript_vanilla_typeorm
|
|
|
|
```
|
2022-09-07 01:55:32 +03:00
|
|
|
|
2023-07-29 15:27:03 +03:00
|
|
|
Run the Benchmarks V Part
|
2022-08-08 04:38:38 +03:00
|
|
|
|
2023-07-29 15:27:03 +03:00
|
|
|
```sh
|
|
|
|
v run v_vweb_orm
|
|
|
|
```
|
2022-08-08 04:38:38 +03:00
|
|
|
|
2023-07-29 15:27:03 +03:00
|
|
|
Run the Chart
|
2022-08-08 04:38:38 +03:00
|
|
|
|
2023-07-29 15:27:03 +03:00
|
|
|
```
|
|
|
|
cd chart/ && v run .
|
|
|
|
```
|
2022-08-08 04:38:38 +03:00
|
|
|
|
2023-07-29 15:27:03 +03:00
|
|
|
## Dockerfile
|
2022-08-08 04:38:38 +03:00
|
|
|
|
2023-07-29 15:27:03 +03:00
|
|
|
> [docker build] => Docker image\
|
|
|
|
> [docker run] => Docker container
|
2022-08-08 04:38:38 +03:00
|
|
|
|
2023-07-29 15:27:03 +03:00
|
|
|
```sh
|
|
|
|
sudo docker build -t <name> .
|
|
|
|
sudo docker run --name <container name> --interactive --tty --publish 3001:3001 <name>
|
|
|
|
v run .
|
|
|
|
# A message like `[Vweb] Running app on http://localhost:3001/` should appear
|
|
|
|
exit
|
|
|
|
```
|
2022-09-07 01:55:32 +03:00
|
|
|
|
2023-07-29 15:27:03 +03:00
|
|
|
## Implementing New Benchmarks in V
|
|
|
|
|
|
|
|
In `v_vweb_orm/src/main.v`, create a route that returns a `Response` struct.
|
2022-09-07 01:55:32 +03:00
|
|
|
|
|
|
|
```v ignore
|
|
|
|
['/sqlite-memory/:count']
|
|
|
|
pub fn (mut app App) sqlite_memory(count int) vweb.Result {
|
|
|
|
mut insert_stopwatchs := []int{}
|
|
|
|
mut select_stopwatchs := []int{}
|
|
|
|
mut update_stopwatchs := []int{}
|
|
|
|
|
|
|
|
mut sw := time.new_stopwatch()
|
|
|
|
|
|
|
|
mut db := sqlite.connect(':memory:') or { panic(err) }
|
|
|
|
|
|
|
|
sql db {
|
|
|
|
create table Task
|
2023-04-04 08:23:06 +03:00
|
|
|
}!
|
2022-09-07 01:55:32 +03:00
|
|
|
|
|
|
|
task_model := Task{
|
|
|
|
title: 'a'
|
|
|
|
status: 'done'
|
|
|
|
}
|
|
|
|
|
|
|
|
for i := 0; i < count; i++ {
|
|
|
|
sw.start()
|
|
|
|
sql db {
|
|
|
|
insert task_model into Task
|
2023-04-04 08:23:06 +03:00
|
|
|
} or { []Task{} }
|
2022-09-07 01:55:32 +03:00
|
|
|
sw.stop()
|
|
|
|
insert_stopwatchs << int(sw.end - sw.start)
|
|
|
|
}
|
|
|
|
|
|
|
|
sql db {
|
|
|
|
drop table Task
|
2023-04-04 08:23:06 +03:00
|
|
|
}!
|
2022-09-07 01:55:32 +03:00
|
|
|
|
|
|
|
response := Response{
|
2023-07-29 15:27:03 +03:00
|
|
|
insert: insert_stopwatchs
|
|
|
|
@select: select_stopwatchs
|
|
|
|
update: update_stopwatchs
|
2022-09-07 01:55:32 +03:00
|
|
|
}
|
|
|
|
return app.json(response)
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2023-07-29 15:27:03 +03:00
|
|
|
In `chart/main.v`, create a service to request the benchmark data and decode the response as
|
|
|
|
`FrameworkBenchmarkResponse`.
|
2022-09-07 01:55:32 +03:00
|
|
|
|
|
|
|
```v ignore
|
|
|
|
fn typescript_sqlite_memory() ?FrameworkBenchmarkResponse {
|
2022-11-15 16:53:13 +03:00
|
|
|
url := 'http://localhost:3000/sqlite-memory/${benchmark_loop_length}'
|
2022-09-07 01:55:32 +03:00
|
|
|
res := http.get(url) or { panic(err) }
|
2022-10-26 11:26:28 +03:00
|
|
|
framework_benchmark_response := json.decode(FrameworkBenchmarkResponse, res.body)!
|
2022-09-07 01:55:32 +03:00
|
|
|
return framework_benchmark_response
|
|
|
|
}
|
|
|
|
```
|
2022-08-08 04:38:38 +03:00
|
|
|
|
2023-07-29 15:27:03 +03:00
|
|
|
Then update `insert_framework_benchmark_times()`, `select_framework_benchmark_times()` and
|
|
|
|
`update_framework_benchmark_times()` to include the `numbers := FrameworkPlatform{` for the newly
|
|
|
|
added function.
|
2022-08-08 04:38:38 +03:00
|
|
|
|
2023-07-29 15:27:03 +03:00
|
|
|
## Roadmap
|
2022-08-08 04:38:38 +03:00
|
|
|
|
|
|
|
02/09/2022
|
2023-07-29 15:27:03 +03:00
|
|
|
|
2022-08-08 04:38:38 +03:00
|
|
|
- [ ] select bench (easy)
|
2022-10-26 11:26:28 +03:00
|
|
|
- [ ] vsql (easy)
|