Debian Codegraph @

gprofng/testsuite/gprofng.display/jsynprog/Sub_Routine.java

raw symbols SCIP
1 /* Copyright (C) 2021-2025 Free Software Foundation, Inc.
2 Contributed by Oracle.
3
4 This file is part of GNU Binutils.
5
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)
9 any later version.
10
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.
15
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. */
20
21 // This is subclass of Routine, overrides one method
22
23 public class Sub_Routine extends Routine {
24 private static native double cTimer();
25
26 /*
27 ** Calls another method c() many times, overridden methos
28 */
29 public int add_int(int scale) {
30 int w = 0;
31 int kmax = 100*scale;
32 if (scale == 1) {
33 kmax /= 100;
34 }
35 double tEnd = jsynprog.Timer() + jsynprog.testtime;
36 do { w = 0;
37 for (int k=0 ; k<kmax; k++) {
38 w = addcall(w) + 1;
39 }
40 } while (jsynprog.Timer() < tEnd);
41 return w;
42 }
43
44 private static int addcall(int x) {
45 int jmax = 100;
46 int imax = 10;
47 for (int j=0; j<jmax;j++) {
48 for (int i=0; i<imax; i++) {
49 x = (i%2==0)?x:(x + 1);
50 }
51 }
52 return x;
53 }
54
55 public int naptime(int k, int scale)
56 {
57 int i;
58 int imax = k * scale;
59
60 try {
61 for (i = 0; i < imax; i++) {
62 System.out.println(i + " sleeping");
63 Thread.currentThread().sleep(10);
64 i=i+1;
65 }
66 } catch (InterruptedException e) {e.printStackTrace();}
67 System.out.println("In naptime");
68 return 0;
69 }
70
71 }