Skip to content

Commit

Permalink
fix(bench): fix sozo bench (#2601)
Browse files Browse the repository at this point in the history
* wip

* benches: fix sozo benchmark
  • Loading branch information
glihm authored Oct 31, 2024
1 parent 861d0b6 commit aa039c0
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 32 deletions.
10 changes: 5 additions & 5 deletions crates/benches/contracts/Scarb.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@ version = 1

[[package]]
name = "benches"
version = "0.4.4"
version = "1.0.0-rc.0"
dependencies = [
"dojo",
]

[[package]]
name = "dojo"
version = "0.4.4"
source = "git+https://github.com/dojoengine/dojo#37f41d585f549013a73ca189034b0471f1e81731"
version = "1.0.0-rc.0"
source = "git+https://github.com/dojoengine/dojo?tag=v1.0.0-rc.0#f4199aec570a395278b8c8748bc46e2f6be3d0c7"
dependencies = [
"dojo_plugin",
]

[[package]]
name = "dojo_plugin"
version = "0.3.11"
source = "git+https://github.com/dojoengine/dojo?tag=v0.3.11#1e651b5d4d3b79b14a7d8aa29a92062fcb9e6659"
version = "2.8.4"
source = "git+https://github.com/dojoengine/dojo?tag=v1.0.0-rc.0#f4199aec570a395278b8c8748bc46e2f6be3d0c7"
25 changes: 6 additions & 19 deletions crates/benches/contracts/Scarb.toml
Original file line number Diff line number Diff line change
@@ -1,24 +1,11 @@
[package]
cairo-version = "2.4.0"
cairo-version = "=2.8.4"
name = "benches"
version = "0.4.4"
version = "1.0.0-rc.0"

[cairo]
sierra-replace-ids = true
[[target.starknet-contract]]
build-external-contracts = ["dojo::world::world_contract::world"]

[dependencies]
dojo = { git = "https://github.com/dojoengine/dojo", version = "0.4.4" }

[[target.dojo]]

[tool.dojo]
initializer_class_hash = "0xbeef"

[tool.dojo.env]
# rpc_url = "http://localhost:5050/"
# Default account for katana with seed = 0
account_address = "0x2af9427c5a277474c079a1283c880ee8a6f0f8fbf73ce969c08d88befec1bba"
private_key = "0x1800000000300000180000000000030000000000003006001800006600"

[tool.dojo.world.namespace]
default = "benches"
dojo = { git = "https://github.com/dojoengine/dojo", tag = "v1.0.0-rc.0" }
starknet = "=2.8.4"
30 changes: 30 additions & 0 deletions crates/benches/contracts/dojo_dev.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[world]
description = "Bench world."
name = "bench"
seed = "bench"

[env]
rpc_url = "http://localhost:5050/"
# Default account for katana with seed = 0
account_address = "0x127fd5f1fe78a71f8bcd1fec63e3fe2f0486b6ecd5c86a0466c3a21fa5cfcec"
private_key = "0xc5b2fcab997346f3ea1c00b002ecf6f382c5f9c9659a3894eb783c5320f912"
#world_address = "0x077c0dc7c1aba7f8842aff393ce6aa71fa675b4ced1bc927f7fc971b6acd92fc"

[namespace]
default = "ns"
mappings = { "ns" = ["c1", "M"], "ns2" = ["c1", "M"] }

[init_call_args]
"ns-c1" = ["0xfffe"]
"ns2-c1" = ["0xfffe"]

[writers]
"ns" = ["ns-c1", "ns-c2"]
"ns-M" = ["ns-c2", "ns-c1", "ns2-c1"]

[owners]
"ns" = ["ns-c1"]

[migration]
order_inits = ["ns-c2", "ns-c1"]
skip_contracts = ["ns-c3"]
9 changes: 1 addition & 8 deletions crates/dojo/test-utils/src/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ use std::{env, fs, io};

use assert_fs::TempDir;
use camino::{Utf8Path, Utf8PathBuf};
use scarb::compiler::plugin::CairoPluginRepository;
use scarb::compiler::{CompilationUnit, CompilerRepository, Profile};
use scarb::compiler::{CompilationUnit, Profile};
use scarb::core::{Config, TargetKind};
use scarb::ops;
use scarb::ops::{CompileOpts, FeaturesOpts, FeaturesSelector};
Expand Down Expand Up @@ -297,10 +296,6 @@ pub fn copy_project_temp(
/// * `path` - The path to the Scarb.toml file to build the config for.
/// * `profile` - The profile to use for the config.
pub fn build_test_config(path: &str, profile: Profile) -> anyhow::Result<Config> {
let compilers = CompilerRepository::empty();

let cairo_plugins = CairoPluginRepository::empty();

// If the cache_dir is not overriden, we can't run tests in parallel.
let cache_dir = TempDir::new().unwrap();

Expand All @@ -310,9 +305,7 @@ pub fn build_test_config(path: &str, profile: Profile) -> anyhow::Result<Config>
.global_cache_dir_override(Some(Utf8Path::from_path(cache_dir.path()).unwrap()))
.ui_verbosity(Verbosity::Verbose)
.log_filter_directive(env::var_os("SCARB_LOG"))
.compilers(compilers)
.profile(profile)
.cairo_plugins(cairo_plugins)
.build()
}

Expand Down
1 change: 1 addition & 0 deletions output_sozo.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test build/Sozo.Cold ... bench: 4521852125 ns/iter (+/- 0)

0 comments on commit aa039c0

Please sign in to comment.