Browse Source

Added benchmark for goal symbol switching (#556)

pull/558/head
Iban Eguia 4 years ago committed by GitHub
parent
commit
8b3d52b5f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 16
      Cargo.lock
  2. 24
      boa/benches/parser.rs
  3. 6
      boa/src/builtins/math/tests.rs

16
Cargo.lock generated

@ -144,9 +144,9 @@ dependencies = [
[[package]]
name = "cc"
version = "1.0.56"
version = "1.0.58"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "77c1f1d60091c1b73e2b1f4560ab419204b178e625fa945ded7b660becd2bd46"
checksum = "f9a06fb2e53271d7c279ec1efea6ab691c35a2ae67ec0d91d7acec0caf13b518"
[[package]]
name = "cfg-if"
@ -365,9 +365,9 @@ dependencies = [
[[package]]
name = "hermit-abi"
version = "0.1.14"
version = "0.1.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b9586eedd4ce6b3c498bc3b4dd92fc9f11166aa908a914071953768066c67909"
checksum = "3deed196b6e7f9e44a2ae8d94225d80302d81208b1bb673fd21fe634645c85a9"
dependencies = [
"libc",
]
@ -425,9 +425,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]]
name = "libc"
version = "0.2.71"
version = "0.2.72"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9457b06509d27052635f90d6466700c65095fdf75409b3fbdd903e988b886f49"
checksum = "a9f8082297d534141b30c8d39e9b1773713ab50fdbe4ff30f750d063b3bfd701"
[[package]]
name = "lock_api"
@ -483,9 +483,9 @@ dependencies = [
[[package]]
name = "memoffset"
version = "0.5.4"
version = "0.5.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b4fc2c02a7e374099d4ee95a193111f72d2110197fe200272371758f6c3643d8"
checksum = "c198b026e1bbf08a937e94c6c60f9ec4a2267f5b0d2eec9c1b21b061ce2be55f"
dependencies = [
"autocfg",
]

24
boa/benches/parser.rs

@ -111,11 +111,35 @@ fn long_file_parser(c: &mut Criterion) {
fs::remove_file(FILE_NAME).unwrap_or_else(|_| panic!("could not remove {}", FILE_NAME));
}
static GOAL_SYMBOL_SWITCH: &str = r#"
function foo(regex, num) {}
let i = 0;
while (i < 1000000) {
foo(/ab+c/, 5.0/5);
i++;
}
"#;
fn goal_symbol_switch(c: &mut Criterion) {
// We include the lexing in the benchmarks, since they will get together soon, anyways.
c.bench_function("Goal Symbols (Parser)", move |b| {
b.iter(|| {
let mut lexer = Lexer::new(black_box(GOAL_SYMBOL_SWITCH));
lexer.lex().expect("failed to lex");
Parser::new(&black_box(lexer.tokens)).parse_all()
})
});
}
criterion_group!(
parser,
expression_parser,
hello_world_parser,
for_loop_parser,
long_file_parser,
goal_symbol_switch,
);
criterion_main!(parser);

6
boa/src/builtins/math/tests.rs

@ -184,6 +184,7 @@ fn ceil() {
}
#[test]
#[allow(clippy::many_single_char_names)]
fn clz32() {
let realm = Realm::create();
let mut engine = Interpreter::new(realm);
@ -280,6 +281,7 @@ fn exp() {
}
#[test]
#[allow(clippy::many_single_char_names)]
fn expm1() {
let realm = Realm::create();
let mut engine = Interpreter::new(realm);
@ -331,6 +333,7 @@ fn floor() {
}
#[test]
#[allow(clippy::many_single_char_names)]
fn fround() {
let realm = Realm::create();
let mut engine = Interpreter::new(realm);
@ -364,6 +367,7 @@ fn fround() {
}
#[test]
#[allow(clippy::many_single_char_names)]
fn hypot() {
let realm = Realm::create();
let mut engine = Interpreter::new(realm);
@ -397,6 +401,7 @@ fn hypot() {
}
#[test]
#[allow(clippy::many_single_char_names)]
fn imul() {
let realm = Realm::create();
let mut engine = Interpreter::new(realm);
@ -448,6 +453,7 @@ fn log() {
}
#[test]
#[allow(clippy::many_single_char_names)]
fn log1p() {
let realm = Realm::create();
let mut engine = Interpreter::new(realm);

Loading…
Cancel
Save