Closed PauloCotrim closed 2 years ago
@PauloCotrim thank you for your contribution. So what you wrote as a comment is that C# .Net code?
@PauloCotrim thank you for your contribution. So what you wrote as a comment is that C# .Net code?
Yes. Sorry.
@PauloCotrim ah okay. Thank you. Do you know which docker image is best to use for this and how best to build/run this code? (the commands)
(I found this on Docker Hub)
I also don't know when I will be able to dive into C# to make that work. If you could contribute a pull-request which contains all the components to make it work, that would be great!
You can put your source file into src/leibniz.cs
. Then you could add the commands and docker image to make it run to the Earthfile.
Here is an example from Java:
java:
# Using a dedicated image due to the packages on alpine being not up to date.
FROM eclipse-temurin:19_36-jdk-alpine
COPY ./src/rounds.txt ./
COPY +build/scbench ./
COPY ./src/leibniz.java ./
RUN --no-cache javac leibniz.java
# TODO: Change scbench to be able to handle Java version. For now it's static.
# $ java -version
# openjdk version "19" 2022-09-20
# OpenJDK Runtime Environment Temurin-19+36 (build 19+36)
# OpenJDK 64-Bit Server VM Temurin-19+36 (build 19+36, mixed mode, sharing)
RUN --no-cache ./scbench "java leibniz" -i $iterations -l "echo 19.36" --export json --lang "Java"
SAVE ARTIFACT ./scbench-summary.json AS LOCAL ./results/java.json
To run it on your machine, you need Docker and earthly installed.
I've merged this to get the next branch up to date. But I converted your request into an issue. (#28)
using System.IO;
var data = String.Empty;
try { data = File.ReadAllText("rounds.txt", System.Text.Encoding.UTF8); } catch (IOException err) { Console.WriteLine($"Couldn't read file:\n {err.Message}"); }
int rounds = int.Parse(data.Replace("\n", "").Replace("\r", ""));
double pi = 1; double x = 1;
for (int i = 2; i < rounds + 2; i++) { x = -1; pi += (x / (2 i - 1)); }
pi *= 4; Console.WriteLine(pi);