jsynprog Program Structure and Control Flow
The jsynprog experiment is a simple application designed to demonstrate the
amount of time it takes to perform various tests, such as vector/array manipulation,
recursion, integer/double addition, memory allocation, system calls, and calls to native
code using JNI. The experiment consists of the following source files:
- jsynprog.java: The main entry point, containing the required
public static void main(String[] args) method.
- Intface.java: A simple interface that defines two methods for adding numbers
together: public int add_int(), and public double add_double().
- Routine.java: Implements the methods of Intface and defines additional
methods that test garbage collection, inner classes, recursion, indirect recursion, array
operations, vector operations, and system calls.
- Sub_Routine.java: Subclass of Routine that overrides the
add_int() method.
- jsynprog.h: Header file used by cloop.cc
- cloop.cc: C++ code for native methods called by jsynprog.
Control flow through the experiment begins and ends with jsynprog.main.
While in main, the program performs the following individual tests, in the following order,
by calling methods of other classes such as Routine.memalloc and
Sub_Routine.add_double.
- Test 1: Routine.memalloc: Triggers garbage collection in the JVM by creating
large memory allocations.
- Test 2: Routine.add_int: Uses nested loops to repeatedly add a set of integers.
- Test 3: Routine.add_double: Uses nested loops to repeatedly add a set of doubles.
- Test 4: Sub_Routine.add_int: Overrides the add_int test to provide
different behavior.
- Test 5: Routine.has_inner_class: Defines and uses an inner classes, local to
the method.
- Test 6: Routine.recurse: Demonstrates the use of direct recursion; this method
calls itself many times.
- Test 7: Routine.bounce: Demonstrates the use of indirect recursion; this method
calls another method, which in turn calls this method.
- Test 8: Routine.array_op: Allocates two large arrays, then performs a copy
operation on them.
- Test 9: Routine.vector_op: Allocates a large Vector then performs operations
to add or remove elements from it.
- Test 10: Routine.sys_op: Spends some time in system calls, using
java.lang.System.currentTimeMillis().
- Test 11: jsynprog.jni_JavaJavaC: Demonstrates the use of JNI: A Java method
calls another Java method, which calls a C function.
- Test 12: jsynprog.JavaCC: Demonstrates the use of JNI: A Java method calls a C
function, which calls another C function.
- Test 13: jsynprog.JavaCJava: Demonstrates the use of JNI: A Java method calls a
C function, which calls a Java method.
Previous | Next
Can't find what you are looking for?
Submit your comments at http://www.sun.com/hwdocs/feedback.
Legal Notices