Skip to content

Commit

Permalink
Merge branch 'master' into enhance-readme-with-screencast-visualization-
Browse files Browse the repository at this point in the history
  • Loading branch information
juandiegocv27 authored Aug 14, 2024
2 parents 44f4c73 + dffe4b9 commit 7139514
Show file tree
Hide file tree
Showing 10 changed files with 111 additions and 56 deletions.
55 changes: 55 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Coverage
on:
push:
branches:
- master
pull_request:
env:
RUSTFLAGS: "-D warnings"

jobs:
coverage:
runs-on: ${{ matrix.platform }}
name: "${{ matrix.example }} - ${{ matrix.platform }}"
strategy:
matrix:
platform: [macos-latest]
toolchain: [stable]
steps:
- uses: actions/checkout@v3
- name: Install Homebrew
run: |
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
- name: Install LLVM
run: brew install llvm
- name: Add LLVM to PATH
run: echo "/opt/homebrew/opt/llvm/bin" >> $GITHUB_PATH
- name: Install cargo-llvm-cov
run: brew install cargo-llvm-cov
- name: Llvm version
run: llvm-config --version
- name: Clang version
run: clang --version
- name: "${{ matrix.toolchain }} with rustfmt, and wasm32"
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.toolchain }}
target: wasm32-unknown-unknown
- name: Set Default Toolchain
run: rustup override set ${{ matrix.toolchain }}
- name: Rust version
run: rustc --version --verbose
- name: Add rust-src component
run: rustup component add rust-src --toolchain ${{ matrix.toolchain }}
- name: Verify Rust Toolchain
run: rustup show
- name: Generate code coverage
run: cargo +${{ matrix.toolchain }} llvm-cov --lcov --output-path llvm-cov-output.lcov
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4
with:
fail_ci_if_error: true
files: ./llvm-cov-output.lcov
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true
2 changes: 1 addition & 1 deletion examples/adder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ crate-type = ["cdylib"]
near-sdk = { path = "../../near-sdk" }

[dev-dependencies]
near-workspaces = "0.11.0"
near-workspaces = "0.11.1"
tokio = { version = "1.14", features = ["full"] }
anyhow = "1.0"
near-abi = "0.4.0"
Expand Down
2 changes: 1 addition & 1 deletion examples/callback-results/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ crate-type = ["cdylib"]
near-sdk = { path = "../../near-sdk" }

[dev-dependencies]
near-workspaces = "0.11.0"
near-workspaces = "0.11.1"
tokio = { version = "1.14", features = ["full"] }
anyhow = "1.0"
near-sdk = { path = "../../near-sdk", features = ["unit-testing"] }
Expand Down
2 changes: 1 addition & 1 deletion examples/cross-contract-calls/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ anyhow = "1.0"
near-sdk = { path = "../../near-sdk", features = ["default", "unit-testing"] }
test-case = "2.0"
tokio = { version = "1.14", features = ["full"] }
near-workspaces = "0.11.0"
near-workspaces = "0.11.1"

cross-contract-high-level = { path = "./high-level" }
cross-contract-low-level = { path = "./low-level" }
Expand Down
2 changes: 1 addition & 1 deletion examples/factory-contract/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ edition = "2021"
anyhow = "1.0"
test-case = "2.0"
tokio = { version = "1.14", features = ["full"] }
near-workspaces = "0.11.0"
near-workspaces = "0.11.1"
near-sdk = { path = "../../near-sdk", features = ["unit-testing"] }

[profile.release]
Expand Down
2 changes: 1 addition & 1 deletion examples/fungible-token/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ edition = "2021"
anyhow = "1.0"
near-sdk = { path = "../../near-sdk", features = ["unit-testing"] }
tokio = { version = "1.14", features = ["full"] }
near-workspaces = "0.11.0"
near-workspaces = "0.11.1"

[profile.release]
codegen-units = 1
Expand Down
2 changes: 1 addition & 1 deletion examples/lockable-fungible-token/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ near-sdk = { path = "../../near-sdk", features = ["legacy"] }
anyhow = "1.0"
tokio = { version = "1.14", features = ["full"] }
near-sdk = { path = "../../near-sdk", features = ["unit-testing"] }
near-workspaces = "0.11.0"
near-workspaces = "0.11.1"

[profile.release]
codegen-units = 1
Expand Down
4 changes: 2 additions & 2 deletions examples/non-fungible-token/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ edition = "2021"
[dev-dependencies]
anyhow = "1.0"
near-contract-standards = { path = "../../near-contract-standards" }
near-sdk = { path = "../../near-sdk", features = ["unit-testing"] }
near-sdk = { path = "../../near-sdk", features = ["unit-testing"] }
tokio = { version = "1.14", features = ["full"] }
near-workspaces = "0.11.0"
near-workspaces = "0.11.1"

[profile.release]
codegen-units = 1
Expand Down
12 changes: 6 additions & 6 deletions near-sdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ schemars = { version = "0.8.8", optional = true }
near-abi = { version = "0.4.0", features = [
"__chunked-entries",
], optional = true }
near-vm-runner = { version = "0.23", optional = true }
near-primitives-core = { version = "0.23", optional = true }
near-primitives = { version = "0.23", optional = true }
near-crypto = { version = "0.23", default-features = false, optional = true }
near-parameters = { version = "0.23", optional = true }
near-vm-runner = { version = "0.24", optional = true }
near-primitives-core = { version = "0.24", optional = true }
near-primitives = { version = "0.24", optional = true }
near-crypto = { version = "0.24", default-features = false, optional = true }
near-parameters = { version = "0.24", optional = true }

[dev-dependencies]
near-sdk = { path = ".", features = ["legacy", "unit-testing"] }
Expand All @@ -63,7 +63,7 @@ rand_chacha = "0.3.1"
near-rng = "0.1.1"
near-abi = { version = "0.4.0", features = ["__chunked-entries"] }
symbolic-debuginfo = "12"
near-workspaces = { version = "0.10.1", features = ["unstable"] }
near-workspaces = { version = "0.11.1", features = ["unstable"] }
anyhow = "1.0"
tokio = { version = "1", features = ["full"] }
strum = "0.25.0"
Expand Down
84 changes: 42 additions & 42 deletions near-sdk/tests/store_performance_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,14 @@ async fn insert_and_remove() -> anyhow::Result<()> {
// insert test, max_iterations here is the number of elements to insert. It's used to measure
// relative performance.
for (col, max_iterations) in collection_types.map(|col| match col {
Collection::TreeMap => (col, 340),
Collection::IterableSet => (col, 340),
Collection::IterableMap => (col, 350),
Collection::UnorderedSet => (col, 340),
Collection::UnorderedMap => (col, 350),
Collection::LookupMap => (col, 600),
Collection::LookupSet => (col, 970),
Collection::Vector => (col, 1000),
Collection::TreeMap => (col, 365),
Collection::IterableSet => (col, 370),
Collection::IterableMap => (col, 370),
Collection::UnorderedSet => (col, 360),
Collection::UnorderedMap => (col, 365),
Collection::LookupMap => (col, 650),
Collection::LookupSet => (col, 1020),
Collection::Vector => (col, 1080),
}) {
let total_gas = account
.call(&contract_id, "insert")
Expand All @@ -143,14 +143,14 @@ async fn insert_and_remove() -> anyhow::Result<()> {
// remove test, max_iterations here is the number of elements to remove. It's used to measure
// relative performance.
for (col, max_iterations) in collection_types.map(|col| match col {
Collection::TreeMap => (col, 220),
Collection::IterableSet => (col, 120),
Collection::IterableMap => (col, 115),
Collection::UnorderedSet => (col, 220),
Collection::UnorderedMap => (col, 220),
Collection::LookupMap => (col, 480),
Collection::LookupSet => (col, 970),
Collection::Vector => (col, 500),
Collection::TreeMap => (col, 230),
Collection::IterableSet => (col, 130),
Collection::IterableMap => (col, 120),
Collection::UnorderedSet => (col, 240),
Collection::UnorderedMap => (col, 250),
Collection::LookupMap => (col, 520),
Collection::LookupSet => (col, 1050),
Collection::Vector => (col, 530),
}) {
let total_gas = account
.call(&contract_id, "remove")
Expand Down Expand Up @@ -198,11 +198,11 @@ async fn iter() -> anyhow::Result<()> {
// It's used to measure relative performance.
for (col, repeat) in collection_types.map(|col| match col {
Collection::TreeMap => (col, 5),
Collection::IterableSet => (col, 20),
Collection::IterableMap => (col, 9),
Collection::UnorderedSet => (col, 18),
Collection::UnorderedMap => (col, 8),
Collection::Vector => (col, 19),
Collection::IterableSet => (col, 22),
Collection::IterableMap => (col, 10),
Collection::UnorderedSet => (col, 20),
Collection::UnorderedMap => (col, 9),
Collection::Vector => (col, 22),
_ => (col, 0),
}) {
let total_gas = account
Expand Down Expand Up @@ -249,12 +249,12 @@ async fn random_access() -> anyhow::Result<()> {
// iter, repeat here is the number that reflects how many times we retrieve a random element.
// It's used to measure relative performance.
for (col, repeat) in collection_types.map(|col| match col {
Collection::TreeMap => (col, 14),
Collection::IterableSet => (col, 1600),
Collection::IterableMap => (col, 720),
Collection::UnorderedSet => (col, 37),
Collection::UnorderedMap => (col, 33),
Collection::Vector => (col, 1600),
Collection::TreeMap => (col, 15),
Collection::IterableSet => (col, 1750),
Collection::IterableMap => (col, 745),
Collection::UnorderedSet => (col, 41),
Collection::UnorderedMap => (col, 36),
Collection::Vector => (col, 1700),
_ => (col, 0),
}) {
let total_gas = account
Expand Down Expand Up @@ -303,13 +303,13 @@ async fn contains() -> anyhow::Result<()> {
// contains test, repeat here is the number of times we check all the elements in each collection.
// It's used to measure relative performance.
for (col, repeat) in collection_types.map(|col| match col {
Collection::TreeMap => (col, 12),
Collection::IterableSet => (col, 11),
Collection::IterableMap => (col, 12),
Collection::UnorderedSet => (col, 11),
Collection::UnorderedMap => (col, 12),
Collection::LookupMap => (col, 16),
Collection::LookupSet => (col, 14),
Collection::TreeMap => (col, 13),
Collection::IterableSet => (col, 12),
Collection::IterableMap => (col, 13),
Collection::UnorderedSet => (col, 12),
Collection::UnorderedMap => (col, 13),
Collection::LookupMap => (col, 17),
Collection::LookupSet => (col, 15),
_ => (col, 0),
}) {
let total_gas = account
Expand Down Expand Up @@ -369,10 +369,10 @@ async fn iterable_vs_unordered() -> anyhow::Result<()> {
// iter, repeat here is the number of times we iterate through the whole collection. It's used to
// measure relative performance.
for (col, repeat) in collection_types.map(|col| match col {
Collection::IterableSet => (col, 240000),
Collection::IterableMap => (col, 130000),
Collection::UnorderedSet => (col, 260),
Collection::UnorderedMap => (col, 260),
Collection::IterableSet => (col, 260000),
Collection::IterableMap => (col, 135000),
Collection::UnorderedSet => (col, 280),
Collection::UnorderedMap => (col, 270),
_ => (col, 0),
}) {
let total_gas = account
Expand All @@ -391,10 +391,10 @@ async fn iterable_vs_unordered() -> anyhow::Result<()> {
// random access, repeat here is the number of times we try to access an element in the
// collection. It's used to measure relative performance.
for (col, repeat) in &collection_types.map(|col| match col {
Collection::IterableSet => (col, 540000),
Collection::IterableMap => (col, 260000),
Collection::UnorderedSet => (col, 255),
Collection::UnorderedMap => (col, 255),
Collection::IterableSet => (col, 600000),
Collection::IterableMap => (col, 280000),
Collection::UnorderedSet => (col, 280),
Collection::UnorderedMap => (col, 260),
_ => (col, 0),
}) {
let total_gas = account
Expand Down

0 comments on commit 7139514

Please sign in to comment.