KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > perfmsr > core > PerformanceMonitor


1 /*******************************************************************************
2  * Copyright (c) 2003, 2004 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.perfmsr.core;
12
13
14 /**
15  * Some natives for PerformanceMonitorWindows.
16  * (We cannot fold them into the PerformanceMonitorWindows because this would break the natives
17  * and we don't want to rebuild them yet).
18  */

19 public class PerformanceMonitor {
20         
21     /**
22      * ivjperf - name of the library that implements the native methods.
23      */

24     private static final String JavaDoc NATIVE_LIBRARY_NAME= "ivjperf"; //$NON-NLS-1$
25

26     /**
27      * Is the native library loaded? 0-don't know, 1-no, 2-yes
28      */

29     private static int fgIsLoaded= 0;
30     
31     /**
32      * Answer true if the native library for this class has been successfully
33      * loaded. If the load has not been attempted yet, try to load it.
34      * @return true if native library has been successfully loaded
35      */

36     public static boolean isLoaded() {
37         if (fgIsLoaded == 0) {
38             try {
39                 System.loadLibrary(NATIVE_LIBRARY_NAME);
40                 fgIsLoaded= 2;
41             } catch (Throwable JavaDoc e) {
42                 e.printStackTrace();
43                 fgIsLoaded= 1;
44             }
45         }
46         return fgIsLoaded == 2;
47     }
48     
49     /**
50      * Calls the Windows GetPerformanceInfo function
51      * @param counters any array of counters that corresponds to the Windows
52      * PERFORMANCE_INFORMATION structure.
53      */

54     public static native void nativeGetPerformanceInfo(long[] counters);
55     
56     public static native boolean nativeGetPerformanceCounters(long[] counters);
57     
58     public static native String JavaDoc nativeGetUUID();
59 }
60
Popular Tags