summaryrefslogtreecommitdiff
path: root/core/http_bench.rs
diff options
context:
space:
mode:
authorRyan Dahl <ry@tinyclouds.org>2019-04-08 10:12:43 -0400
committerGitHub <noreply@github.com>2019-04-08 10:12:43 -0400
commitf7fdb90fd51e340ea598c055bb3573d3cdfbdaa8 (patch)
tree40db117b3a9fd2ac70e3b5551195e21eef464138 /core/http_bench.rs
parentcdb72afd8d91978573f0fa897844aee853983b44 (diff)
core: snapshot improvements (#2052)
* Moves how snapshots are supplied to the Isolate. Previously they were given by Behavior::startup_data() but it was only called once at startup. It makes more sense (and simplifies Behavior) to pass it to the constructor of Isolate. * Adds new libdeno type deno_snapshot instead of overloading deno_buf. * Adds new libdeno method to delete snapshot deno_snapshot_delete(). * Renames deno_get_snapshot() to deno_snapshot_new(). * Makes StartupData hold references to snapshots. This was implicit when it previously held a deno_buf but is made explicit now. Note that include_bytes!() returns a &'static [u8] and we want to avoid copying that.
Diffstat (limited to 'core/http_bench.rs')
-rw-r--r--core/http_bench.rs19
1 files changed, 9 insertions, 10 deletions
diff --git a/core/http_bench.rs b/core/http_bench.rs
index 37965510f..fced92bf8 100644
--- a/core/http_bench.rs
+++ b/core/http_bench.rs
@@ -99,15 +99,6 @@ pub type HttpBenchOp = dyn Future<Item = i32, Error = std::io::Error> + Send;
struct HttpBench();
impl Behavior for HttpBench {
- fn startup_data(&mut self) -> Option<StartupData> {
- let js_source = include_str!("http_bench.js");
-
- Some(StartupData::Script(Script {
- source: js_source.to_string(),
- filename: "http_bench.js".to_string(),
- }))
- }
-
fn dispatch(
&mut self,
control: &[u8],
@@ -168,7 +159,15 @@ fn main() {
// TODO currently isolate.execute() must be run inside tokio, hence the
// lazy(). It would be nice to not have that contraint. Probably requires
// using v8::MicrotasksPolicy::kExplicit
- let isolate = deno::Isolate::new(HttpBench());
+
+ let js_source = include_str!("http_bench.js");
+
+ let startup_data = StartupData::Script(Script {
+ source: js_source,
+ filename: "http_bench.js",
+ });
+
+ let isolate = deno::Isolate::new(startup_data, HttpBench());
isolate.then(|r| {
js_check(r);