Skip to content

Commit 19cd026

Browse files
johnfgibsonViralBShah
authored andcommitted
Fix for issue #25291: inconsistency in python printfd microbenchmark (#25456)
1 parent 09f7213 commit 19cd026

File tree

12 files changed

+29
-23
lines changed

12 files changed

+29
-23
lines changed

test/perf/micro/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ bin/perf%: perf.c perf.h
5858
bin/fperf%: perf.f90
5959
mkdir -p mods/$@ #Modules for each binary go in separate directories
6060
# $(FC) $(FFLAGS) -Jmods/$@ -O$* $< -o $@ $(LIBBLAS) -L$(LIBMDIR) $(LIBM) -lpthread
61-
$(FC) $(FFLAGS) -Jmods/$@ -O$* $< -o $@ -lblas -L$(LIBMDIR) $(LIBM) -lpthread
61+
$(FC) $(FFLAGS) -Jmods/$@ -O$* $< -o $@ -lopenblas -L$(LIBMDIR) $(LIBM) -lpthread
6262

6363
benchmarks/c.csv: \
6464
benchmarks/c0.csv \

test/perf/micro/bin/table.pl

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
# "stata" => ["Stata" , $stata_ver ],
5252
);
5353

54-
our @systems = qw(c julia lua fortran go java javascript mathematica python matlab r octave);
54+
our @systems = qw(c julia lua go fortran java javascript matlab mathematica python r octave);
5555

5656
print qq[<!-- Table generated by the Perl script test/perf/micro/bin/table.pl in the main julia repository -->\n];
5757
print qq[<table class="benchmarks">\n];

test/perf/micro/java/src/main/java/PerfPure.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ void printfd(int n) {
149149
PrintStream ps = new PrintStream(f);
150150
long i = 0;
151151
for (i = 0; i < n; i++) {
152-
ps.println(i+" "+i);
152+
ps.println(i + " " + (i+1));
153153
}
154154
ps.close();
155155
} catch (FileNotFoundException e) {

test/perf/micro/perf.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ timeit("parse_integers", parseintperf, 1000)
4444
printfdperf = function(t) {
4545
fd<-file("/dev/null")
4646
for (i in 1:t) {
47-
s = sprintf("%d %d", i, i)
47+
s = sprintf("%d %d", i, i+1)
4848
writeLines(s, fd)
4949
}
5050
}

test/perf/micro/perf.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ void printfd(int n) {
223223
FILE *f = fopen("/dev/null", "w");
224224
long i = 0;
225225
for (i = 0; i < n; i++)
226-
fprintf(f, "%ld %ld\n", i, i);
226+
fprintf(f, "%ld %ld\n", i, i+1);
227227
fclose(f);
228228
}
229229

test/perf/micro/perf.f90

+2-2
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,9 @@ integer function parse_int(s, base) result(n)
193193
subroutine printfd(n)
194194
integer, intent(in) :: n
195195
integer :: i , unit
196-
open(unit=1, file="foo")
196+
open(unit=1, file="/dev/null")
197197
do i = 1, n
198-
write(unit=1, fmt=*) i, i
198+
write(unit=1, fmt=*) i, i+1
199199
end do
200200
close(unit=1)
201201
end subroutine

test/perf/micro/perf.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ func printfd(n int) {
6464
w := bufio.NewWriter(f)
6565

6666
for i := 0; i < n; i++ {
67-
_, err = fmt.Fprintf(w, "%d %d\n", i, i)
67+
_, err = fmt.Fprintf(w, "%d %d\n", i, i+1)
6868
}
6969
w.Flush()
7070
f.Close()

test/perf/micro/perf.jl

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# This file is a part of Julia. License is MIT: https://julialang.org/license
22

33
using Test
4+
using Printf
5+
46

57
include("../perfutil.jl")
68

test/perf/micro/perf.m

+2-2
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ function timeit(name, func, varargin)
107107
%% mandelbrot set: complex arithmetic and comprehensions %%
108108

109109
function r = abs2(z)
110-
r = real(z)*real(z) + imag(z)*imag(z)
110+
r = real(z)*real(z) + imag(z)*imag(z);
111111
end
112112

113113
function n = mandel(z)
@@ -228,7 +228,7 @@ function timeit(name, func, varargin)
228228
function printfd(n)
229229
f = fopen('/dev/null','w');
230230
for i = 1:n
231-
fprintf(f, '%d %d\n', i, i);
231+
fprintf(f, '%d %d\n', i, i + 1);
232232
end
233233
fclose(f);
234234
end

test/perf/micro/perf.nb

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ printfdperf[t_] := Module[
7272
filename = "/dev/null";
7373
fd = OpenWrite[filename];
7474
For[i=1, i<=t, ++i,
75-
WriteString[fd, StringForm["`1` `2`\n", i, i]];
75+
WriteString[fd, StringForm["`1` `2`\n", i, i + 1]];
7676
];
7777
Close[fd];
7878
];

test/perf/micro/perf.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def parse_int(t):
105105
def printfd(t):
106106
f = open("/dev/null", "w")
107107
for i in range(1,t):
108-
f.write("%d %d\n")
108+
f.write("{:d} {:d}\n".format(i, i+1))
109109
f.close()
110110

111111

test/perf/perfutil.jl

+15-11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# This file is a part of Julia. License is MIT: https://julialang.org/license
22

3+
using Printf
4+
35
const mintrials = 5
46
const mintime = 2000.0
57
print_output = isempty(ARGS)
@@ -69,19 +71,21 @@ end
6971

7072
macro timeit(ex,name,desc,group...)
7173
quote
72-
t = Float64[]
73-
tot = 0.0
74-
i = 0
75-
while i < mintrials || tot < mintime
76-
e = 1000*(@elapsed $(esc(ex)))
77-
tot += e
78-
if i > 0
79-
# warm up on first iteration
80-
push!(t, e)
74+
let
75+
t = Float64[]
76+
tot = 0.0
77+
i = 0
78+
while i < mintrials || tot < mintime
79+
e = 1000*(@elapsed $(esc(ex)))
80+
tot += e
81+
if i > 0
82+
# warm up on first iteration
83+
push!(t, e)
84+
end
85+
i += 1
8186
end
82-
i += 1
87+
@output_timings t $(esc(name)) $(esc(desc)) $(esc(group))
8388
end
84-
@output_timings t $(esc(name)) $(esc(desc)) $(esc(group))
8589
end
8690
end
8791

0 commit comments

Comments
 (0)