1 /* Copyright (C) 2021-2024 Free Software Foundation, Inc.
4 This file is part of GNU Binutils.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3, or (at your option)
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, 51 Franklin Street - Fifth Floor, Boston,
19 MA 02110-1301, USA. */
28 typedef long long hrtime_t
;
31 hrtime_t
gethrvtime();
33 static jdouble testtime
= 3.0 * 1e9
;
37 JNIEXPORT jdouble JNICALL
38 Java_jsynprog_Timer (JNIEnv
*env
, jclass obj
)
48 JNIEXPORT jdouble JNICALL
49 Java_jsynprog_cTimer (JNIEnv
*env
, jclass obj
)
54 vstart
= gethrvtime();
55 jd
= (double)(vstart
);
59 JNIEXPORT jdouble JNICALL
60 Java_jsynprog_computeSet (JNIEnv
*env
, jclass obj
)
65 s
= getenv("SP_COLLECTOR_TEST_TIMER");
75 JNIEXPORT jint JNICALL
76 Java_jsynprog_JavaJavaC (JNIEnv
*env
, jclass obj
, jint n
, int scale
)
78 // fprintf(stderr, "Entering Java_jsynprog_JavaJavaC, scale = %d\n", scale);
81 for (int i
=0; i
<imax
; i
++) {
87 JNIEXPORT
void JNICALL
88 Java_jsynprog_JavaCC (JNIEnv
*env
, jclass obj
, int scale
)
90 fprintf(stderr
, "Entering Java_jsynprog_JavaCC, scale = %d\n", scale
);
96 double tEnd
= gethrtime() + testtime
;
98 for (int i
=0; i
<imax
; i
++) {
101 } while (gethrtime() < tEnd
);
105 for (int j
=0; j
<100000;j
++) {
111 JNIEXPORT
void JNICALL
112 Java_jsynprog_JavaCJava (JNIEnv
*env
, jclass obj
, int scale
)
114 fprintf(stderr
, "Entering Java_jsynprog_JavaCJava, scale = %d\n", scale
);
116 jmethodID mid
= (env
)->GetStaticMethodID(obj
, "javafunc", "(I)I");
118 fprintf(stderr
, "Can't get jmethodID for \"javafunc\", \"(I)I\"\n");
121 fprintf(stderr
, "Calling CallStaticIntMethod, scale = %d\n", scale
);
122 pnum
= (env
)->CallStaticIntMethod(obj
, mid
, scale
);
125 JNIEXPORT jint JNICALL
126 Java_jsynprog_isJVMPI (JNIEnv
*env
, jclass obj
)
128 char *jvmpi
= getenv("SP_COLLECTOR_USE_JVMPI");
130 return jvmpi
? 1 : 0;