Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Jamaica.doc
Скачиваний:
6
Добавлен:
01.03.2025
Размер:
1.89 Mб
Скачать

1.2. Приложение демонстрирующее основные функциональные возможности rmi api of Jamaica

Попробовать создать исполняемый файл демонстрирующий работу RMI. Переходи в каталог /home/rtj/jamaica/qnx/examples/rmi и выполняем команду make. В результате получаем 2 исполняемых файла. Запускаем их на выполнение в ОС QNX

The demo consists of two applications, a server and a client program, that need to be run concurrently. The server, named RMIServer, may be called with an optional argument, denoting the number of seconds to stay active and listen for client connections. If called without an argument, the server stays active for 60 seconds. It is best to run the server in the background by starting it with.

2 Building and Running an Example Java Program

Дополнительные программы расположены в каталоге /home/rtj/jamaica. Он имеет 2 подкаталога: linux и qnx.

In order to build and run the HelloWorld example on the host platform, go to the corresponding examples directory:

> cd /home/rtj/jamaica/linux/examples/HelloWorld

First, the Java source code needs to be compiled to byte code. This is done with jamaicac, Jamaica’s version of javac. The source code resides in the src folder, and we wish to generate byte code in a classes folder, which must be created if not already present:

> mkdir classes

> jamaicac -d classes src/HelloWorld.java

Before generating an executable, we test the byte code with the Jamaica virtual

machine:

> jamaicavm -cp classes HelloWorld

Having convinced ourselves that the program exhibits the desired behaviour, we now generate an executable with the Jamaica Builder. In the context of the JamaicaVM Tools, one speaks of building an application.

> jamaicabuilder -cp classes -interpret -setGraphics=none HelloWorld

The builder has now generated the executable HelloWorld.

> ./HelloWorld

2 Performance Optimization

The most fundamental measure employed by the Jamaica Builder to improve the performance of an application is to statically compile those parts that contribute most to the overall runtime. These parts are identified in a profile run of the application. Identifying these parts is called profiling. The profiling information is used by the Builder to decide which parts of an application need to be compiled and whether further optimizations such as inlining the code are necessary.

2.1. Creating a profile

The builder’s -profile option and the jamaicavmp command provide simple means to profile an application. Setting the -profile option enables profiling. The builder will then link the application with the profiling version of the JamaicaVM libraries.

During profiling the Jamaica Virtual Machine counts, among other things, the number of bytecode instructions executed within every method of the application. The number of instructions can be used as a measure for the time spent in each method.

At the end of execution, the total number of bytecode instructions executed by each method is written to a file with the name of the main class of the Java application and the suffix .prof, such that it can be used for further processing. ’Hot spots’ (the most likely sources for further performance enhancements by optimization) in the application can easily be determined using this file.

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]