mirror of
https://github.com/theoludwig/programming-challenges.git
synced 2024-12-08 00:45:29 +01:00
perf: use optimization options for Rust and gcc
This commit is contained in:
parent
5e5a248238
commit
df539a41c0
@ -10,7 +10,7 @@ int main() {
|
|||||||
size_t string_length = strlen(string);
|
size_t string_length = strlen(string);
|
||||||
char* result = malloc(sizeof(char*) * (string_length + 1));
|
char* result = malloc(sizeof(char*) * (string_length + 1));
|
||||||
for (size_t index = 0; index < string_length; index++) {
|
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];
|
char value_to_search = string[index];
|
||||||
size_t iteration = index;
|
size_t iteration = index;
|
||||||
while (iteration < string_length && string[iteration] == value_to_search) {
|
while (iteration < string_length && string[iteration] == value_to_search) {
|
||||||
@ -18,7 +18,7 @@ int main() {
|
|||||||
iteration++;
|
iteration++;
|
||||||
}
|
}
|
||||||
char* number_of_appearances_string = malloc(sizeof(char*) * (string_length + 1));
|
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_many(result, number_of_appearances_string);
|
||||||
character_append(result, value_to_search);
|
character_append(result, value_to_search);
|
||||||
index += number_of_appearances - 1;
|
index += number_of_appearances - 1;
|
||||||
|
@ -2,6 +2,6 @@ FROM gcc:12.2.0
|
|||||||
|
|
||||||
WORKDIR /usr/app
|
WORKDIR /usr/app
|
||||||
COPY ./ /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"]
|
CMD ["./solution.exe"]
|
||||||
|
@ -2,6 +2,6 @@ FROM gcc:12.2.0
|
|||||||
|
|
||||||
WORKDIR /usr/app
|
WORKDIR /usr/app
|
||||||
COPY ./ /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"]
|
CMD ["./solution.exe"]
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
FROM dart:2.17.7
|
FROM dart:2.18.1
|
||||||
|
|
||||||
WORKDIR /usr/app
|
WORKDIR /usr/app
|
||||||
COPY ./ /usr/app
|
COPY ./ /usr/app
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
FROM openjdk:17
|
FROM openjdk:19
|
||||||
|
|
||||||
WORKDIR /usr/app
|
WORKDIR /usr/app
|
||||||
COPY ./ /usr/app
|
COPY ./ /usr/app
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
FROM rust:1.63.0
|
FROM rust:1.64.0
|
||||||
|
|
||||||
WORKDIR /usr/app
|
WORKDIR /usr/app
|
||||||
COPY ./ /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"]
|
CMD ["./solution"]
|
||||||
|
Loading…
Reference in New Issue
Block a user