|
2 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this
|
3 | 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
4 | 4 |
|
| 5 | +extern crate test; |
| 6 | + |
5 | 7 | use std::borrow::Cow::{self, Borrowed};
|
6 | 8 | use std::fs::File;
|
7 | 9 | use std::io::{self, Write};
|
8 | 10 | use std::path::Path;
|
9 | 11 | use std::process::Command;
|
10 | 12 | use rustc_serialize::json::{self, Json, ToJson};
|
11 | 13 | use tempdir::TempDir;
|
| 14 | +use self::test::Bencher; |
12 | 15 |
|
13 | 16 | use encoding::label::encoding_from_whatwg_label;
|
14 | 17 |
|
@@ -576,6 +579,22 @@ impl ToJson for Color {
|
576 | 579 | }
|
577 | 580 | }
|
578 | 581 |
|
| 582 | +const BACKGROUND_IMAGE: &'static str = include_str!("big-data-url.css"); |
| 583 | + |
| 584 | +#[bench] |
| 585 | +fn unquoted_url(b: &mut Bencher) { |
| 586 | + b.iter(|| { |
| 587 | + let mut input = Parser::new(BACKGROUND_IMAGE); |
| 588 | + input.look_for_var_functions(); |
| 589 | + |
| 590 | + let result = input.try(|input| input.expect_url()); |
| 591 | + |
| 592 | + assert!(result.is_ok()); |
| 593 | + |
| 594 | + input.seen_var_functions(); |
| 595 | + (result.is_ok(), input.seen_var_functions()) |
| 596 | + }) |
| 597 | +} |
579 | 598 |
|
580 | 599 | struct JsonParser;
|
581 | 600 |
|
@@ -667,7 +686,6 @@ fn component_values_to_json(input: &mut Parser) -> Vec<Json> {
|
667 | 686 | values
|
668 | 687 | }
|
669 | 688 |
|
670 |
| - |
671 | 689 | fn one_component_value_to_json(token: Token, input: &mut Parser) -> Json {
|
672 | 690 | fn numeric(value: NumericValue) -> Vec<json::Json> {
|
673 | 691 | vec![
|
|
0 commit comments