Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
guillermocalvo committed May 8, 2024
2 parents 7d4b3ec + 2a64857 commit 68eca2c
Show file tree
Hide file tree
Showing 30 changed files with 119 additions and 77 deletions.
File renamed without changes.
28 changes: 13 additions & 15 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,46 +59,47 @@ jobs:
# SHALLOW CLONE
# ================================
- name: Shallow clone
uses: actions/checkout@v3
uses: actions/checkout@v4

# ================================
# SET UP JDK
# ================================
- name: Set up JDK
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-package: jdk
java-version: 21

# ================================
# SETUP GRADLE
# SET UP GRADLE
# ================================
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
- name: Set up Gradle
uses: gradle/actions/setup-gradle@v3
with:
cache-read-only: ${{ github.ref != 'refs/heads/main' && github.ref != 'refs/heads/develop' }}
build-scan-publish: true
build-scan-terms-of-use-url: "https://gradle.com/help/legal-terms-of-use"
build-scan-terms-of-use-agree: "yes"
cache-read-only: ${{ github.ref_name != github.event.repository.default_branch && github.ref_name != 'develop' }}

# ================================
# BENCHMARK
# ================================
- name: Benchmark
uses: gradle/gradle-build-action@v2
env:
JMH_VERSION: ${{ inputs.jmhVersion }}
JMH_BENCHMARK_MODE: ${{ inputs.benchmarkMode }}
JMH_WARMUP_ITERATIONS: ${{ inputs.warmupIterations }}
JMH_ITERATIONS: ${{ inputs.iterations }}
JMH_FORK: ${{ inputs.fork }}
JMH_THREADS: ${{ inputs.threads }}
with:
arguments: jmh -x jmhReport --info --scan
run: ./gradlew jmh -x jmhReport

# ================================
# UPLOAD RESULTS
# ================================
- name: Upload Results
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: results.json
path: ./benchmark/build/reports/jmh/results.json
Expand All @@ -108,23 +109,20 @@ jobs:
# ================================
- name: Generate Report
if: ${{ inputs.publish }}
uses: gradle/gradle-build-action@v2
with:
arguments: jmhReport --info --scan
run: ./gradlew jmhReport

# ================================
# MAKE BADGE
# ================================
- name: Make Badge
if: ${{ inputs.publish }}
shell: bash
run: |
SCENARIO="com.leakyabstractions.result.benchmark.SimpleFailureScenario"
SCORE_RESULTS=`jq ".[] | select(.benchmark == \"$SCENARIO.results\").primaryMetric.score" ./benchmark/build/reports/jmh/results.json`
SCORE_EXCEPTIONS=`jq ".[] | select(.benchmark == \"$SCENARIO.exceptions\").primaryMetric.score" ./benchmark/build/reports/jmh/results.json`
TIMES_FASTER=`printf "%.0f\n" $(jq -n "$SCORE_RESULTS / $SCORE_EXCEPTIONS")`
LOGO_CONTENTS=`cat ./benchmark/build/reports/jmh/badge-logo.svg`
echo "According to the benchmark, returning a failed result is $TIMES_FASTER times faster than throwing an exception"
echo "According to the benchmark, returning a failed result is $TIMES_FASTER times faster than throwing an exception" >> $GITHUB_STEP_SUMMARY
jq -n ".schemaVersion |= 1 |
.style |= \"for-the-badge\" |
.labelColor |= \"eee\" |
Expand Down
21 changes: 11 additions & 10 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ jobs:
# SHALLOW CLONE
# ================================
- name: Shallow clone
uses: actions/checkout@v3
uses: actions/checkout@v4

# ================================
# SET UP JDK
# ================================
- name: Set up JDK
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-package: jdk
Expand All @@ -39,20 +39,21 @@ jobs:
# VALIDATE GRADLE WRAPPER
# ================================
- name: Validate Gradle Wrapper
uses: gradle/wrapper-validation-action@v1
uses: gradle/wrapper-validation-action@v3

# ================================
# SETUP GRADLE
# SET UP GRADLE
# ================================
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
- name: Set up Gradle
uses: gradle/actions/setup-gradle@v3
with:
cache-read-only: ${{ github.ref != 'refs/heads/main' && github.ref != 'refs/heads/develop' }}
build-scan-publish: true
build-scan-terms-of-use-url: "https://gradle.com/help/legal-terms-of-use"
build-scan-terms-of-use-agree: "yes"
cache-read-only: ${{ github.ref_name != github.event.repository.default_branch && github.ref_name != 'develop' }}

# ================================
# CHECK
# ================================
- name: Check
uses: gradle/gradle-build-action@v2
with:
arguments: check --info --scan
run: ./gradlew check
41 changes: 41 additions & 0 deletions .github/workflows/dependencies.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@

# Submit dependencies
name: Dependencies

on:
push:
branches:
- main

permissions:
contents: write

jobs:
dependencies:

name: Submit dependencies
runs-on: ubuntu-latest

steps:

# ================================
# SHALLOW CLONE
# ================================
- name: Shallow clone
uses: actions/checkout@v4

# ================================
# SET UP JDK
# ================================
- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-package: jdk
java-version: 21

# ================================
# SUBMIT DEPENDENCIES
# ================================
- name: Generate and submit dependency graph
uses: gradle/actions/dependency-submission@v3
4 changes: 2 additions & 2 deletions .github/workflows/update-gradle-wrapper.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
# SHALLOW CLONE
# ================================
- name: Shallow clone
uses: actions/checkout@v3
uses: actions/checkout@v4

# ================================
# UPDATE GRADLE WRAPPER
Expand All @@ -27,5 +27,5 @@ jobs:
uses: gradle-update/update-gradle-wrapper-action@v1
with:
release-channel: stable
base-branch: main
base-branch: develop
target-branch: develop
2 changes: 1 addition & 1 deletion NOTICE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright 2023 Guillermo Calvo
Copyright 2024 Guillermo Calvo

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
21 changes: 19 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,28 @@ public Result<String, ComplexFailure> usingResults(int number) {

## Getting Started

To run the benchmarks locally, execute this command:
> [!IMPORTANT]
>
> The report you can see [here][BENCHMARK] was generated on a [GitHub-hosted runner][GITHUB_HOSTED_RUNNER] using the latest [Ubuntu][UBUNTU_RUNNER] image and the latest [Azul Zulu OpenJDK][AZUL_ZULU_OPENJDK] version.
> Performance measurements may vary depending on different factors such as architecture, operating system, or Java virtual machine.
> Please remember that you should run your own benchmarks to make informed decisions for your specific project.

To run the [JMH benchmarks][JMH] locally, execute this command:

```sh
./gradlew jhm
```

Once they are complete, a report will be generated automatically by [JMH Visualizer][JMH_VISUALIZER].

```sh
start ./benchmark/build/reports/jmh/index.html
```


## Author

Copyright 2023 [Guillermo Calvo][AUTHOR].
Copyright 2024 [Guillermo Calvo][AUTHOR].

[![][GUILLERMO_IMAGE]][GUILLERMO]

Expand Down Expand Up @@ -116,9 +128,14 @@ See the License for the specific language governing permissions and limitations


[AUTHOR]: https://github.com/guillermocalvo/
[AZUL_ZULU_OPENJDK]: https://github.com/actions/setup-java?tab=readme-ov-file#azul-zulu-openjdk
[BADGE_TIMES_FASTER]: https://img.shields.io/endpoint?url=https://dev.leakyabstractions.com/result-benchmark/badge.json
[BENCHMARK]: https://dev.leakyabstractions.com/result-benchmark/
[GITHUB_HOSTED_RUNNER]: https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners/about-github-hosted-runners#using-a-github-hosted-runner
[GUILLERMO]: https://guillermo.dev/
[GUILLERMO_IMAGE]: https://guillermo.dev/assets/images/thumb.png
[JMH]: https://openjdk.org/projects/code-tools/jmh/
[JMH_VISUALIZER]: https://github.com/jzillmann/jmh-visualizer/
[RESULT]: https://dev.leakyabstractions.com/result/
[TIMES_FASTER]: https://dev.leakyabstractions.com/result-benchmark/
[UBUNTU_RUNNER]: https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners/about-github-hosted-runners#standard-github-hosted-runners-for-public-repositories
4 changes: 2 additions & 2 deletions benchmark/build.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
plugins {
id 'java-library'
id "me.champeau.jmh" version "0.7.2"
id "io.morethan.jmhreport" version "0.9.0"
id "io.morethan.jmhreport" version "0.9.6"
}

repositories {
mavenCentral()
}

dependencies {
implementation platform("com.leakyabstractions:result-bom:0.2.0.1")
implementation platform("com.leakyabstractions:result-bom:0.3.2.0")
implementation "com.leakyabstractions:result"
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 Guillermo Calvo
* Copyright 2024 Guillermo Calvo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 Guillermo Calvo
* Copyright 2024 Guillermo Calvo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 Guillermo Calvo
* Copyright 2024 Guillermo Calvo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 Guillermo Calvo
* Copyright 2024 Guillermo Calvo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 Guillermo Calvo
* Copyright 2024 Guillermo Calvo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 Guillermo Calvo
* Copyright 2024 Guillermo Calvo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 Guillermo Calvo
* Copyright 2024 Guillermo Calvo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 Guillermo Calvo
* Copyright 2024 Guillermo Calvo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 Guillermo Calvo
* Copyright 2024 Guillermo Calvo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 Guillermo Calvo
* Copyright 2024 Guillermo Calvo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 Guillermo Calvo
* Copyright 2024 Guillermo Calvo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 Guillermo Calvo
* Copyright 2024 Guillermo Calvo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 Guillermo Calvo
* Copyright 2024 Guillermo Calvo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 Guillermo Calvo
* Copyright 2024 Guillermo Calvo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,5 @@
/*
* Copyright 2023 Guillermo Calvo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* Copyright 2023 Guillermo Calvo
* Copyright 2024 Guillermo Calvo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 Guillermo Calvo
* Copyright 2024 Guillermo Calvo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 Guillermo Calvo
* Copyright 2024 Guillermo Calvo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 Guillermo Calvo
* Copyright 2024 Guillermo Calvo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Binary file modified buildSrc/src/main/resources/jmh-visualizer.zip
Binary file not shown.
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
Loading

0 comments on commit 68eca2c

Please sign in to comment.