当前位置: 首页>>代码示例>>Java>>正文


Java Statistics.setStatisticsEnabled方法代码示例

本文整理汇总了Java中org.hibernate.stat.Statistics.setStatisticsEnabled方法的典型用法代码示例。如果您正苦于以下问题:Java Statistics.setStatisticsEnabled方法的具体用法?Java Statistics.setStatisticsEnabled怎么用?Java Statistics.setStatisticsEnabled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.hibernate.stat.Statistics的用法示例。


在下文中一共展示了Statistics.setStatisticsEnabled方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: perfTest

import org.hibernate.stat.Statistics; //导入方法依赖的package包/类
@Test(enabled = false)
public <T extends ObjectType> void perfTest() throws Exception {
    Statistics stats = getFactory().getStatistics();
    stats.setStatisticsEnabled(true);

    final File OBJECTS_FILE = new File("./src/test/resources/10k-users.xml");
    List<PrismObject<? extends Objectable>> elements = prismContext.parserFor(OBJECTS_FILE).parseObjects();

    long previousCycle = 0;
    long time = System.currentTimeMillis();
    for (int i = 0; i < elements.size(); i++) {
        if (i % 500 == 0) {
            LOGGER.info("Previous cycle time {}. Next cycle: {}", new Object[]{
                    (System.currentTimeMillis() - time - previousCycle), i});
            previousCycle = System.currentTimeMillis() - time;
        }

        PrismObject<T> object = (PrismObject<T>) elements.get(i);
        repositoryService.addObject(object, null, new OperationResult("add performance test"));
    }
    LOGGER.info("Time to add objects ({}): {}",
            new Object[]{elements.size(), (System.currentTimeMillis() - time)});

    stats.logSummary();
}
 
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:26,代码来源:AddGetObjectTest.java

示例2: testSessionStats

import org.hibernate.stat.Statistics; //导入方法依赖的package包/类
public void testSessionStats() throws Exception {
	
	SessionFactory sf = getSessions();
	Statistics stats = sf.getStatistics();
	boolean isStats = stats.isStatisticsEnabled();
	stats.clear();
	stats.setStatisticsEnabled(true);
	Session s = sf.openSession();
	assertEquals( 1, stats.getSessionOpenCount() );
	s.close();
	assertEquals( 1, stats.getSessionCloseCount() );
	s = sf.openSession();
	Transaction tx = s.beginTransaction();
	A a = new A();
	a.setName("mya");
	s.save(a);
	a.setName("b");
	tx.commit();
	s.close();
	assertEquals( 1, stats.getFlushCount() );
	s = sf.openSession();
	tx = s.beginTransaction();
	String hql = "from " + A.class.getName();
	Query q = s.createQuery(hql);
	q.list();
	tx.commit();
	s.close();
	assertEquals(1, stats.getQueryExecutionCount() );
	assertEquals(1, stats.getQueryStatistics(hql).getExecutionCount() );
	
	stats.setStatisticsEnabled(isStats);
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:33,代码来源:StatisticsTest.java

示例3: testSessionStatistics

import org.hibernate.stat.Statistics; //导入方法依赖的package包/类
public void testSessionStatistics() throws Exception {
	Session s = openSession();
	Transaction tx = s.beginTransaction();
	Statistics stats = getSessions().getStatistics();
	stats.clear();
	boolean isStats = stats.isStatisticsEnabled();
	stats.setStatisticsEnabled(true);
	Continent europe = fillDb(s);
	tx.commit();
	s.clear();
	tx = s.beginTransaction();
	SessionStatistics sessionStats = s.getStatistics();
	assertEquals( 0, sessionStats.getEntityKeys().size() );
	assertEquals( 0, sessionStats.getEntityCount() );
	assertEquals( 0, sessionStats.getCollectionKeys().size() );
	assertEquals( 0, sessionStats.getCollectionCount() );
	europe = (Continent) s.get( Continent.class, europe.getId() );
	Hibernate.initialize( europe.getCountries() );
	Hibernate.initialize( europe.getCountries().iterator().next() );
	assertEquals( 2, sessionStats.getEntityKeys().size() );
	assertEquals( 2, sessionStats.getEntityCount() );
	assertEquals( 1, sessionStats.getCollectionKeys().size() );
	assertEquals( 1, sessionStats.getCollectionCount() );
	tx.commit();
	s.close();

	stats.setStatisticsEnabled( isStats);

}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:30,代码来源:SessionStatsTest.java

示例4: checkFetchJoin

import org.hibernate.stat.Statistics; //导入方法依赖的package包/类
@Test
public void checkFetchJoin() {
    Statistics statistics = sessionFactory.getStatistics();
    statistics.setStatisticsEnabled(true);

    DataTablesOutput<A> output = getOutput(input);

    assertThat(output.getRecordsFiltered()).isEqualTo(3);
    assertThat(statistics.getPrepareStatementCount()).isEqualTo(2);
    assertThat(statistics.getEntityLoadCount()).isEqualTo(3 /* A */ + 3 /* C */);
}
 
开发者ID:darrachequesne,项目名称:spring-data-jpa-datatables,代码行数:12,代码来源:RelationshipsRepositoryTest.java

示例5: getEntityManager

import org.hibernate.stat.Statistics; //导入方法依赖的package包/类
public static EntityManager getEntityManager()
    throws MalformedObjectNameException, NotCompliantMBeanException,
    InstanceAlreadyExistsException, MBeanRegistrationException {
    if (emf == null) {
        emf = Persistence.createEntityManagerFactory(
            Util.getConfig().getString("bard.jpa.unit", "prod")
        );
        final SessionFactory sessionFactory =
            ((HibernateEntityManagerFactory) emf).getSessionFactory();

        ObjectName statsName = new ObjectName("org.hibernate:type=statistics");
        MBeanServer mbeanServer = ManagementFactory.getPlatformMBeanServer();

        final Statistics statistics = sessionFactory.getStatistics();
        statistics.setStatisticsEnabled(true);
        Object statisticsMBean = Proxy.newProxyInstance(DBManager.class.getClassLoader(),
            new Class<?>[] {StatisticsMXBean.class}, new InvocationHandler() {

                @Override
                public Object invoke(Object proxy, Method method, Object[] args)
                    throws Throwable {
                    return method.invoke(statistics, args);
                }
            });

        mbeanServer.registerMBean(statisticsMBean, statsName);

    }
    return emf.createEntityManager();
}
 
开发者ID:wb14123,项目名称:bard,代码行数:31,代码来源:DBManager.java

示例6: JobsMemoryMonitorRunner

import org.hibernate.stat.Statistics; //导入方法依赖的package包/类
public JobsMemoryMonitorRunner(Statistics statistics, SchedulerState schedulerState) {
    statistics.setStatisticsEnabled(true);
    this.stats = statistics;
    this.schedulerState = schedulerState;
}
 
开发者ID:ow2-proactive,项目名称:scheduling,代码行数:6,代码来源:JobsMemoryMonitorRunner.java

示例7: getHibernateStatistics

import org.hibernate.stat.Statistics; //导入方法依赖的package包/类
public Statistics getHibernateStatistics() {
	Statistics stats = this.getSessionFactory().getStatistics();

	stats.setStatisticsEnabled(true);

	return stats;
}
 
开发者ID:mindie,项目名称:Cindy,代码行数:8,代码来源:HibernateDatabase.java


注:本文中的org.hibernate.stat.Statistics.setStatisticsEnabled方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。