Eclipse性能测量框架,Derby数据库不起作用

时间:2015-08-07 06:50:00

标签: java eclipse eclipse-plugin derby

我遇到了以下问题: 我想通过使用org.eclipse.test.performance框架来衡量Eclipse插件的性能。我已经创建了一个测试类和所需的代码。

我完全按照本article中的说明完成所有操作,直到“查看数据”,但我仍然没有工作数据库......

正如您在堆栈跟踪结束时看到的那样“DB中没有新的数据点”。如果我从控制台运行此测试,则除了“java.lang.IllegalStateException”之外没有显示任何内容,但没有显示性能测试结果和数据库信息。

org.eclipse.test.uitestapplication的程序参数:

-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl} -consoleLog
-testpluginsnames com.test.eclipse.performance
-classesnames com.test.eclipse.performance.PerformanceTestCase
-Declipse.perf.dbloc=C:\Users\thupel\MyTestDB
-Declipse.perf.config=build=CRAP;host=LOCAL;jvm=DONTKNOW
formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter
haltOnFailure=false

MyPerformanceTestClass:

package com.test.eclipse.performance;

import org.eclipse.test.performance.Dimension;
import org.eclipse.test.performance.Performance;
import org.eclipse.test.performance.PerformanceMeter;
import org.junit.Test;
import org.junit.Before;

public class PerformanceTestCase
{

    final static String ID = "sample_ID";
    final static String NAME = "sample_Name";

    public PerformanceTestCase() 
    {
        System.out.println("Constructor called");
    }

    @Test
    public void testMyOperation() 
    {
        Performance perf = Performance.getDefault();
        PerformanceMeter performanceMeter = perf.createPerformanceMeter(ID);
        perf.tagAsSummary(performanceMeter, NAME, Dimension.CPU_TIME);

        long a = 0, b = 0;
        try 
        {
            System.out.println("MEASUREMENT STARTED");
            // measuring
            for (int i = 0; i < 10; i++) 
            {
                performanceMeter.start();
                for (int j = 0; j < Math.pow(10, 7); j++) 
                {
                    a = i + a;
                    b = b + a;
                }
                performanceMeter.stop();
            }
            System.out.println("MEASUREMENT FINISHED, b = " + b);
            performanceMeter.commit();
            perf.assertPerformance(performanceMeter);
        } 
        finally 
        {
            performanceMeter.dispose();
        }

    }

    @Before
    public void setup() 
    {
        System.out.println("Startup called");
    }
}

堆栈跟踪:

!SESSION 2015-08-17 15:04:14.153 -----------------------------------------------
eclipse.buildId=unknown
java.version=1.8.0_51
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=en_US
Framework arguments:  -application org.eclipse.test.uitestapplication -testpluginsnames com.test.eclipse.performance -classesnames com.test.eclipse.performance.PerformanceTestCase -Declipse.perf.dbloc=/tmp/derby -Declipse.perf.config=key1=value1;key2=value2; -junitReportOutput C:\Users\thupel\Desktop formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter haltOnFailure=false
Command-line arguments:  -application org.eclipse.test.uitestapplication -data C:\Users\thupel\workspace/../runtime-New_configuration(2) -dev file:C:/Users/thupel/workspace/.metadata/.plugins/org.eclipse.pde.core/New_configuration (2)/dev.properties -os win32 -ws win32 -arch x86_64 -consoleLog -testpluginsnames com.test.eclipse.performance -classesnames com.test.eclipse.performance.PerformanceTestCase -Declipse.perf.dbloc=/tmp/derby -Declipse.perf.config=key1=value1;key2=value2; -junitReportOutput C:\Users\thupel\Desktop formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter haltOnFailure=false
INFO: optional timeout was not specified.
Constructor called
Startup called
MEASUREMENT STARTED
MEASUREMENT FINISHED, b = 14250000225000000
Scenario 'sample_ID' (average over 10 samples):
  Used Java Heap:            0          (95% in [0, 0])               
  Working Set:           718.4K         (95% in [-333.9K, 1.73M])      Measurable effect: 1.82M (1.3 SDs) (required sample size for an effect of 5% of stdev: 6400)
  Committed:               1.1M         (95% in [-312.06K, 2.5M])      Measurable effect: 2.48M (1.3 SDs) (required sample size for an effect of 5% of stdev: 6401)
  Working Set Peak:      158.4K         (95% in [-110.8K, 427.6K])     Measurable effect: 476K (1.3 SDs) (required sample size for an effect of 5% of stdev: 6400)
  Elapsed Process:          25ms        (95% in [19ms, 30ms])          Measurable effect: 8ms (1.3 SDs) (required sample size for an effect of 5% of mean: 513)
  Kernel time:               0ms        (95% in [0ms, 0ms])           
  Page Faults:             463          (95% in [-33, 960])            Measurable effect: 878 (1.3 SDs) (required sample size for an effect of 5% of stdev: 6400)
  CPU Time:                 49ms        (95% in [38ms, 61ms])          Measurable effect: 20ms (1.3 SDs) (required sample size for an effect of 5% of mean: 663)
  GDI Objects:               0          (95% in [0, 0])               


!ENTRY org.eclipse.core.jobs 4 2 2015-08-17 15:04:22.262
!MESSAGE An internal error occurred during: "Setup check".
!STACK 0
java.lang.IllegalStateException: There is no eclipse.launcher property defined
    at org.eclipse.oomph.setup.internal.core.SetupContext.createSelf(SetupContext.java:225)
    at org.eclipse.oomph.setup.ui.SetupUIPlugin.performStartup(SetupUIPlugin.java:416)
    at org.eclipse.oomph.setup.ui.SetupUIPlugin.access$3(SetupUIPlugin.java:310)
    at org.eclipse.oomph.setup.ui.SetupUIPlugin$1$1.run(SetupUIPlugin.java:210)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
no new datapoints in DB
disconnecting from DB

1 个答案:

答案 0 :(得分:0)

基本上我自己解决了这个问题。也许这个答案可以帮助有类似问题的人。

首先我做的(可耻的)错了:

-Declipse.perf.dbloc=C:\Users\thupel\MyTestDB
-Declipse.perf.config=build=CRAP;host=LOCAL;jvm=DONTKNOW 

是VM参数我把它在eclipse运行配置中放入程序参数中是没有意义的,它们需要作为VM参数。

下载“org.eclipse.test.performance”框架的源代码后,我看到在“org”下添加了名为“org.apache.derby.core”的数据库信息交换所需的可选插件.eclipse.test.performance“插件的依赖项。 eclipse wiki上的教程说我应该把它命名为“org.eclipse.derby”,但性能插件不会发现这个,显然它的名字错了......

最后,在我将所有derby jar添加到“org.apache.derby.core”并再次运行性能测试用例后,数据存储在一个名为“MyTestDB \ perfDb”的新derby数据库中。

暂时问题解决了。 :)