From 93c1428098b5132ad58fb7dfe0a85cdefe4e4b10 Mon Sep 17 00:00:00 2001 From: Vikman Fernandez-Castro Date: Fri, 23 Feb 2024 20:44:07 +0100 Subject: [PATCH 1/2] Unify time measuring units in all implementations --- C#/Program.cs | 4 ++-- JS/queens.js | 6 +++--- Java/queens/Main.java | 8 ++++---- PHP/queens.php | 3 ++- Python/queens.py | 4 ++-- 5 files changed, 13 insertions(+), 12 deletions(-) diff --git a/C#/Program.cs b/C#/Program.cs index ba95418..a85886a 100644 --- a/C#/Program.cs +++ b/C#/Program.cs @@ -7,7 +7,7 @@ * February 8, 2013 * * Syntax: queens [-test] [N] - * + * ******************************************************************************/ using System; @@ -42,7 +42,7 @@ static void Main(string[] args) time = DateTime.Now.Ticks - time; if (testing) - Console.WriteLine(chess.Steps + "\t" + chess.Discards + "\t" + time / 10000); + Console.WriteLine(chess.Steps + "\t" + chess.Discards + "\t" + time / 10); else { Console.WriteLine(chess.ToString()); diff --git a/JS/queens.js b/JS/queens.js index 4710523..9f4de47 100644 --- a/JS/queens.js +++ b/JS/queens.js @@ -27,16 +27,16 @@ if (isNaN(n) || n < 4) { var chess = new libchess.Chess(n) var hrtime = process.hrtime() -var time = hrtime[0] + hrtime[1] / 1e9 +var time = hrtime[0] *1e6 + hrtime[1] / 1e3 chess.solve() hrtime = process.hrtime() -time = parseInt((hrtime[0] + hrtime[1] / 1e9 - time) * 1000) +time = parseInt((hrtime[0] *1e6 + hrtime[1] / 1e3 - time)) if (testing) console.log(String(chess.steps()) + "\t" + chess.discards() + "\t" + time) else { console.log(String(chess)) - console.log("Solved in " + chess.steps() + " steps. Time: " + time + " ms.") + console.log("Solved in " + chess.steps() + " steps. Time: " + time / 1000 + " ms.") } diff --git a/Java/queens/Main.java b/Java/queens/Main.java index 4c16303..335f69b 100644 --- a/Java/queens/Main.java +++ b/Java/queens/Main.java @@ -42,16 +42,16 @@ public static void main(String[] args) { } chess = new Chess(n); - time = System.currentTimeMillis(); + time = System.nanoTime(); chess.solve(); - time = System.currentTimeMillis() - time; + time = System.nanoTime() - time; if (testing) { - System.out.println(chess.getSteps() + "\t" + chess.getDiscards() + "\t" + time); + System.out.println(chess.getSteps() + "\t" + chess.getDiscards() + "\t" + time / 1000); } else { System.out.println(chess); System.out.print("Solved in " + chess.getSteps() + " steps. "); - System.out.println("Time: " + time + " ms."); + System.out.println("Time: " + time / 1000000 + " ms."); } } } diff --git a/PHP/queens.php b/PHP/queens.php index 676bc98..4c4a831 100644 --- a/PHP/queens.php +++ b/PHP/queens.php @@ -34,7 +34,7 @@ $chess = new Chess($n); $time = microtime(true); $chess->solve(); -$time = (int)((microtime(true) - $time) * 1000); +$time = (int)((microtime(true) - $time) * 1e6); $steps = $chess->steps(); $discards = $chess->discards(); @@ -42,5 +42,6 @@ echo "$steps\t$discards\t$time\n"; else { echo $chess; + $time /= 1000; echo "Solved in $steps steps. Time: $time ms.\n"; } diff --git a/Python/queens.py b/Python/queens.py index 3d5c1fa..b38943b 100755 --- a/Python/queens.py +++ b/Python/queens.py @@ -37,10 +37,10 @@ chess = Chess(n) time = perf_counter() chess.solve() - time = int((perf_counter() - time) * 1000) + time = int((perf_counter() - time) * 1e6) if testing: print(str(chess.steps()) + "\t" + str(chess.discards()) + "\t" + str(time)); else: print(chess) - print("Solved in", chess.steps(), "steps. Time:", time, "ms.") + print("Solved in", chess.steps(), "steps. Time:", time / 1000, "ms.") From be99c134bd6d87fb26add0c4f84aa49d9c77afd8 Mon Sep 17 00:00:00 2001 From: Vikman Fernandez-Castro Date: Fri, 23 Feb 2024 21:17:49 +0100 Subject: [PATCH 2/2] Change testing parameters at CI workflow --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7a0d834..7f15c56 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,8 +7,8 @@ on: branches: [ "master" ] env: - STEP: 16 - STOP: 256 + STEP: 64 + STOP: 512 TIMEOUT: 1 ATTEMPTS: 3