1
0

Edit README; Improve bench script; Optimize

This commit is contained in:
Jeff 2024-02-19 20:44:26 -05:00
parent c4b51a1ef9
commit 900de8ca4b
3 changed files with 11 additions and 5 deletions

View File

@ -93,6 +93,8 @@ cargo install dust-lang
dust
```
## Benchmarks
## Development Status
Currently, Dust is being prepared for version 1.0. Until then, there may be breaking changes to the language and CLI.

View File

@ -11,7 +11,7 @@ hyperfine \
--shell none \
--parameter-list data_path examples/assets/seaCreatures.json \
--warmup 3 \
"dust -c 'length(json:parse(fs:read_file(\"{data_path}\")))'" \
"target/release/dust -c 'length(json:parse(fs:read_file(\"{data_path}\")))'" \
"jq 'length' {data_path}" \
"node --eval \"require('node:fs').readFile('{data_path}', (err, data)=>{console.log(JSON.parse(data).length)})\"" \
"nu -c 'open {data_path} | length'"
@ -20,7 +20,7 @@ hyperfine \
--shell none \
--parameter-list data_path examples/assets/jq_data.json \
--warmup 3 \
"dust -c 'length(json:parse(fs:read_file(\"{data_path}\")))'" \
"target/release/dust -c 'length(json:parse(fs:read_file(\"{data_path}\")))'" \
"jq 'length' {data_path}" \
"node --eval \"require('node:fs').readFile('{data_path}', (err, data)=>{console.log(JSON.parse(data).length)})\"" \
"nu -c 'open {data_path} | length'"
@ -29,7 +29,7 @@ hyperfine \
--shell none \
--parameter-list data_path dielectron.json \
--warmup 3 \
"dust -c 'length(json:parse(fs:read_file(\"{data_path}\")))'" \
"target/release/dust -c 'length(json:parse(fs:read_file(\"{data_path}\")))'" \
"jq 'length' {data_path}" \
"node --eval \"require('node:fs').readFile('{data_path}', (err, data)=>{console.log(JSON.parse(data).length)})\"" \
"nu -c 'open {data_path} | length'"

View File

@ -1,4 +1,4 @@
use std::fs::read_to_string;
use std::{fs::File, io::Read};
use enum_iterator::{all, Sequence};
use serde::{Deserialize, Serialize};
@ -46,7 +46,11 @@ impl Callable for Fs {
RuntimeError::expect_argument_amount(self.name(), 1, arguments.len())?;
let path = arguments.first().unwrap().as_string()?;
let file_content = read_to_string(path.as_str())?;
let mut file = File::open(path)?;
let file_size = file.metadata()?.len() as usize;
let mut file_content = String::with_capacity(file_size);
file.read_to_string(&mut file_content)?;
Ok(Value::string(file_content))
}