From df539a41c0f544e98933a2553b01bbc552896fc0 Mon Sep 17 00:00:00 2001 From: Divlo Date: Sat, 24 Sep 2022 22:17:07 +0200 Subject: [PATCH] perf: use optimization options for Rust and gcc --- .../solutions/c/function/solution.c | 4 ++-- templates/docker/c/Dockerfile | 2 +- templates/docker/cpp/Dockerfile | 2 +- templates/docker/dart/Dockerfile | 2 +- templates/docker/java/Dockerfile | 2 +- templates/docker/rust/Dockerfile | 4 ++-- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/challenges/look-and-say-sequence-conway/solutions/c/function/solution.c b/challenges/look-and-say-sequence-conway/solutions/c/function/solution.c index 640f6d7..6740664 100644 --- a/challenges/look-and-say-sequence-conway/solutions/c/function/solution.c +++ b/challenges/look-and-say-sequence-conway/solutions/c/function/solution.c @@ -10,7 +10,7 @@ int main() { size_t string_length = strlen(string); char* result = malloc(sizeof(char*) * (string_length + 1)); for (size_t index = 0; index < string_length; index++) { - size_t number_of_appearances = 0; + unsigned char number_of_appearances = 0; char value_to_search = string[index]; size_t iteration = index; while (iteration < string_length && string[iteration] == value_to_search) { @@ -18,7 +18,7 @@ int main() { iteration++; } char* number_of_appearances_string = malloc(sizeof(char*) * (string_length + 1)); - snprintf(number_of_appearances_string, sizeof(result), "%zu", number_of_appearances); + snprintf(number_of_appearances_string, sizeof(result), "%hhu", number_of_appearances); character_append_many(result, number_of_appearances_string); character_append(result, value_to_search); index += number_of_appearances - 1; diff --git a/templates/docker/c/Dockerfile b/templates/docker/c/Dockerfile index c566c35..27df87d 100644 --- a/templates/docker/c/Dockerfile +++ b/templates/docker/c/Dockerfile @@ -2,6 +2,6 @@ FROM gcc:12.2.0 WORKDIR /usr/app COPY ./ /usr/app -RUN gcc ./*.c* -o solution.exe -Wall -Wextra -Wfloat-equal -Wundef -Werror -std=c17 -pedantic -pedantic-errors +RUN gcc ./*.c* -o solution.exe -Wall -Wextra -Wfloat-equal -Wundef -Werror -std=c17 -pedantic -pedantic-errors -O3 CMD ["./solution.exe"] diff --git a/templates/docker/cpp/Dockerfile b/templates/docker/cpp/Dockerfile index 9170656..49b9b36 100644 --- a/templates/docker/cpp/Dockerfile +++ b/templates/docker/cpp/Dockerfile @@ -2,6 +2,6 @@ FROM gcc:12.2.0 WORKDIR /usr/app COPY ./ /usr/app -RUN g++ ./*.cpp* -o solution.exe -Wall -Wextra -Wfloat-equal -Wundef -Werror -std=c++17 -pedantic -pedantic-errors +RUN g++ ./*.cpp* -o solution.exe -Wall -Wextra -Wfloat-equal -Wundef -Werror -std=c++17 -pedantic -pedantic-errors -O3 CMD ["./solution.exe"] diff --git a/templates/docker/dart/Dockerfile b/templates/docker/dart/Dockerfile index 5eee88c..eacc1ac 100644 --- a/templates/docker/dart/Dockerfile +++ b/templates/docker/dart/Dockerfile @@ -1,4 +1,4 @@ -FROM dart:2.17.7 +FROM dart:2.18.1 WORKDIR /usr/app COPY ./ /usr/app diff --git a/templates/docker/java/Dockerfile b/templates/docker/java/Dockerfile index f12fead..95fd684 100644 --- a/templates/docker/java/Dockerfile +++ b/templates/docker/java/Dockerfile @@ -1,4 +1,4 @@ -FROM openjdk:17 +FROM openjdk:19 WORKDIR /usr/app COPY ./ /usr/app diff --git a/templates/docker/rust/Dockerfile b/templates/docker/rust/Dockerfile index 54ac1d3..e3772b3 100644 --- a/templates/docker/rust/Dockerfile +++ b/templates/docker/rust/Dockerfile @@ -1,7 +1,7 @@ -FROM rust:1.63.0 +FROM rust:1.64.0 WORKDIR /usr/app COPY ./ /usr/app -RUN rustc solution.rs +RUN rustc -C debuginfo=0 -C opt-level=3 -C target-cpu=native solution.rs CMD ["./solution"]