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


Java NumberHelper.round方法代码示例

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


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

示例1: stressReturn

import org.openyu.commons.lang.NumberHelper; //导入方法依赖的package包/类
public void stressReturn(String userId, byte[] bytes) {
	//
	messageCounter.incrementAndGet();
	byteCounter.addAndGet(ByteHelper.toByteArray(userId).length);
	byteCounter.addAndGet(bytes.length);
	//
	long end = System.currentTimeMillis();
	long dur = (end - returnBeg);
	double result = NumberHelper.round(byteCounter.get()
			/ (double) dur, 2);
	double kresult = NumberHelper.round(
			(byteCounter.get() / (double) 1024)
					/ (dur / (double) 1000), 2);
	double mbresult = NumberHelper.round((byteCounter.get()
			/ (double) 1024 / (double) 1024)
			/ (dur / (double) 1000), 2);
	//
	System.out.println("send/receive: " + messageCounter.get()
			+ " messages, " + byteCounter.get() + " bytes / " + dur
			+ " ms. = " + result + " BYTES/MS, " + kresult
			+ " K/S, " + mbresult + " MB/S");
}
 
开发者ID:mixaceh,项目名称:openyu-socklet,代码行数:23,代码来源:BenchmarkJavaConnectorImplTest.java

示例2: stressReturn

import org.openyu.commons.lang.NumberHelper; //导入方法依赖的package包/类
public void stressReturn(String userId, byte[] bytes) {
	if (beg == 0) {
		beg = System.currentTimeMillis();
	}
	//
	messageCounter.incrementAndGet();
	byteCounter.addAndGet(ByteHelper.toByteArray(userId).length);
	byteCounter.addAndGet(bytes.length);
	//
	long end = System.currentTimeMillis();
	long dur = (end - beg);
	double result = NumberHelper.round(byteCounter.get() / (double) dur, 2);
	double kresult = NumberHelper.round((byteCounter.get() / (double) 1024) / (dur / (double) 1000), 2);
	double mbresult = NumberHelper
			.round((byteCounter.get() / (double) 1024 / (double) 1024) / (dur / (double) 1000), 2);
	//
	System.out.println("receive: " + messageCounter.get() + " messages, " + byteCounter.get() + " bytes / " + dur
			+ " ms. = " + result + " BYTES/MS, " + kresult + " K/S, " + mbresult + " MB/S");
	//
	sendStressReturn(userId, bytes);
}
 
开发者ID:mixaceh,项目名称:openyu-socklet,代码行数:22,代码来源:FourSymbolSocklet.java

示例3: printResult

import org.openyu.commons.lang.NumberHelper; //导入方法依赖的package包/类
/**
 * 印出結果
 * 
 * @param beg
 * @param byteCounter
 * @param timesCounter
 */
protected static void printResult(long beg, AtomicLong byteCounter, AtomicLong timesCounter) {
	long end = System.currentTimeMillis();
	long dur = (end - beg);
	double result = NumberHelper.round(byteCounter.get() / (double) dur, 2);
	double kresult = NumberHelper.round((byteCounter.get() / (double) 1024) / (dur / (double) 1000), 2);
	double mbresult = NumberHelper
			.round((byteCounter.get() / (double) 1024 / (double) 1024) / (dur / (double) 1000), 2);
	//
	System.out.println(timesCounter.get() + " rows, " + byteCounter.get() + " bytes / " + dur + " ms. = " + result
			+ " BYTES/MS, " + kresult + " K/S, " + mbresult + " MB/S");
}
 
开发者ID:mixaceh,项目名称:openyu-commons,代码行数:19,代码来源:BaseTestSupporter.java

示例4: printBean

import org.openyu.commons.lang.NumberHelper; //导入方法依赖的package包/类
/**
 * Prints the beans.
 */
protected static void printBean() {
	AssertHelper.notNull(applicationContext, "The ApplicationContext must not be null");
	//
	String[] beanNames = applicationContext.getBeanDefinitionNames();
	Arrays.sort(beanNames, Collator.getInstance(java.util.Locale.ENGLISH));
	final String MSG_PATTERN = "#.{0} {1} \"{2}\"";
	// 計算所耗費的記憶體(bytes)
	RuntimeHelper.gc();
	// 原本的記憶體
	long memory = RuntimeHelper.usedMemory();
	//
	StopWatch sw = new StopWatch("Spring beans");
	// System.out.println("=========================================");
	// System.out.println("Spring beans");
	// System.out.println("=========================================");
	for (int i = 0; i < beanNames.length; i++) {
		String className = null;
		String name = beanNames[i];
		sw.start("#." + (i + 1) + " " + name);
		Object bean = null;
		try {
			// when abstract bean will throw exception
			// so set bean="abstract bean"
			bean = applicationContext.getBean(beanNames[i]);
			if (bean == null) {
				className = "NULL CLASS";
			} else {
				className = bean.getClass().getSimpleName();
			}
		} catch (Exception ex) {
			className = "ABSTRACT CLASS";
		}
		sw.stop();
		sw.printResult();

		// StringBuilder msg = new
		// StringBuilder(MessageFormat.format(MSG_PATTERN, (i + 1),
		// className, beanNames[i]));

		// 不是抽象類別
		// if (!abstractBean) {
		// System.out.println(msg);// 顯示黑色
		// } else {
		// System.err.println(msg);// 顯示紅色
		// }

		// System.out.println(msg);
		//
		usedMemory = Math.max(usedMemory, (RuntimeHelper.usedMemory() - memory));
	}
	long durTime = endTime - begTime;
	//
	RuntimeHelper.gc();
	usedMemory = Math.max(usedMemory, (RuntimeHelper.usedMemory() - memory));
	double kb = NumberHelper.round(ByteUnit.BYTE.toKiB(usedMemory), 1);
	double mb = NumberHelper.round(ByteUnit.BYTE.toMiB(usedMemory), 1);
	double sizeOf = NumberHelper.round(ByteUnit.BYTE.toMiB(MemoryHelper.sizeOf(applicationContext)), 1);
	//
	System.out.println("=========================================");
	final String MEMORY_PATTERN = "count: {0}, time: {1} mills., {2} bytes, {3} KB, {4} MB, sizeOf: {5} MB memory used";
	StringBuilder msg = new StringBuilder(
			MessageFormat.format(MEMORY_PATTERN, beanNames.length, durTime, usedMemory, kb, mb, sizeOf));
	System.out.println(msg);
}
 
开发者ID:mixaceh,项目名称:openyu-commons,代码行数:68,代码来源:BaseTestSupporter.java

示例5: main

import org.openyu.commons.lang.NumberHelper; //导入方法依赖的package包/类
/**
 * 從main直接啟動
 * 
 * class path
 * 
 * org/openyu/socklet/bootstrap/client/applicationContext-client1.xml
 * 
 * @param args
 */
public static void main(String args[]) {
	try {
		if (started) {
			throw new IllegalStateException(new StringBuilder().append(ClientBootstrap.class.getSimpleName())
					.append(" was already started").toString());
		}
		//
		double usedMemory = 0d;
		long begTime = System.currentTimeMillis();
		// 計算所耗費的記憶體(bytes)
		RuntimeHelper.gc();
		// 原本的記憶體
		long memory = RuntimeHelper.usedMemory();
		// 建構applicationContext
		buildApplicationContext(args);

		// 建構客戶端控制器
		buildClientControl();
		// 建構客戶端服務
		buildClientService();
		// --------------------------------------------------
		// 啟動
		doStart();
		// --------------------------------------------------
		long endTime = System.currentTimeMillis();
		long durTime = endTime - begTime;
		//
		RuntimeHelper.gc();
		usedMemory = Math.max(usedMemory, (RuntimeHelper.usedMemory() - memory));
		double kb = NumberHelper.round(ByteUnit.BYTE.toKiB(usedMemory), 1);
		double mb = NumberHelper.round(ByteUnit.BYTE.toMiB(usedMemory), 1);
		double sizeOf = NumberHelper.round(ByteUnit.BYTE.toMiB(MemoryHelper.sizeOf(applicationContext)), 1);
		//
		if (started) {
			String MEMORY_PATTERN = "[{0}] start in {1} ms, {2} bytes , {3} KB, {4} MB, sizeOf: {5} MB memory used";
			StringBuilder msg = new StringBuilder(
					MessageFormat.format(MEMORY_PATTERN, id, durTime, usedMemory, kb, mb, sizeOf));
			LOGGER.info(msg.toString());
			//
			// ThreadHelper.loop(50);
		} else {
			LOGGER.error("[" + id + "] started fail");
		}

	} catch (Exception e) {
		clientControl.setVisible(false);
		LOGGER.error(new StringBuilder("[" + id + "] Exception encountered during main()").toString(), e);
		// 結束
		System.exit(0);
	}
}
 
开发者ID:mixaceh,项目名称:openyu-socklet,代码行数:61,代码来源:ClientBootstrap.java

示例6: main

import org.openyu.commons.lang.NumberHelper; //导入方法依赖的package包/类
/**
 * 從main直接啟動,並不是在web下啟動
 * 
 * class path
 * 
 * org/openyu/socklet/bootstrap/server/applicationContext-slave1.xml
 * 
 * ThreadHelper.loop(50);
 * 
 * @param args
 */
public static void main(String args[]) {
	try {
		if (started) {
			throw new IllegalStateException(new StringBuilder().append(AcceptorBootstrap.class.getSimpleName())
					.append(" was already started").toString());
		}
		//
		double usedMemory = 0d;
		long begTime = System.currentTimeMillis();
		// 計算所耗費的記憶體(bytes)
		RuntimeHelper.gc();
		// 原本的記憶體
		long memory = RuntimeHelper.usedMemory();

		// 建構applicationContext
		buildApplicationContext(args);

		// 取得接受器服務
		buildAcceptorService();

		// 啟動
		doStart();
		//
		long endTime = System.currentTimeMillis();
		long durTime = endTime - begTime;
		//
		RuntimeHelper.gc();
		usedMemory = Math.max(usedMemory, (RuntimeHelper.usedMemory() - memory));
		double kb = NumberHelper.round(ByteUnit.BYTE.toKiB(usedMemory), 1);
		double mb = NumberHelper.round(ByteUnit.BYTE.toMiB(usedMemory), 1);
		double sizeOf = NumberHelper.round(ByteUnit.BYTE.toMiB(MemoryHelper.sizeOf(applicationContext)), 1);
		//
		if (started) {
			String MEMORY_PATTERN = "[{0}] ({1}) ({2}) start in {3} ms, {4} bytes, {5} KB, {6} MB, sizeOf: {7} MB memory used";
			StringBuilder msg = new StringBuilder(MessageFormat.format(MEMORY_PATTERN, id, instanceId, outputId,
					durTime, usedMemory, kb, mb, sizeOf));
			LOGGER.info(msg.toString());
			// loop
			ThreadHelper.loop(50);
		} else {
			LOGGER.error("[" + id + "] (" + instanceId + ") (" + outputId + ") started fail");
		}
	} catch (Exception e) {
		started = false;
		LOGGER.error(new StringBuilder("Exception encountered during main()").toString(), e);
		// 結束
		System.exit(0);
	}
}
 
开发者ID:mixaceh,项目名称:openyu-socklet,代码行数:61,代码来源:AcceptorBootstrap.java

示例7: start

import org.openyu.commons.lang.NumberHelper; //导入方法依赖的package包/类
/**
 * 從web上啟動,或其他已經建構的applicationContext來啟動
 * 
 * @param applicationContext
 */
public static void start(ApplicationContext applicationContext) {
	AssertHelper.notNull(applicationContext, "The ApplicationContext must not be null");
	//
	try {
		if (started) {
			throw new IllegalStateException(new StringBuilder().append(AcceptorBootstrap.class.getSimpleName())
					.append(" was already started").toString());
		}
		double usedMemory = 0d;
		long begTime = System.currentTimeMillis();
		// 計算所耗費的記憶體(bytes)
		RuntimeHelper.gc();
		// 原本的記憶體
		long memory = RuntimeHelper.usedMemory();
		// 取得applicationContext
		AcceptorBootstrap.applicationContext = applicationContext;

		// 取得接受器服務
		buildAcceptorService();

		// 啟動
		doStart();
		//
		long endTime = System.currentTimeMillis();
		long durTime = endTime - begTime;
		//
		RuntimeHelper.gc();
		usedMemory = Math.max(usedMemory, (RuntimeHelper.usedMemory() - memory));
		double usedMemoryMB = NumberHelper.round(ByteUnit.BYTE.toMB(usedMemory), 2);
		//
		if (started) {
			String msgPattern = "[{0}] ({1}) ({2}) start in {3} ms, {4} bytes ({5} MB) memory used";
			StringBuilder msg = new StringBuilder(
					MessageFormat.format(msgPattern, id, instanceId, outputId, durTime, usedMemory, usedMemoryMB));
			LOGGER.info(msg.toString());
		} else {
			LOGGER.error("[" + id + "] (" + instanceId + ") (" + outputId + ") started fail");
		}
	} catch (Exception e) {
		started = false;
		LOGGER.error(new StringBuilder("Exception encountered during start()").toString(), e);
	}
}
 
开发者ID:mixaceh,项目名称:openyu-socklet,代码行数:49,代码来源:AcceptorBootstrap.java

示例8: println

import org.openyu.commons.lang.NumberHelper; //导入方法依赖的package包/类
/**
 * PrintlnMemory.
 *
 * @param <T>
 *            the generic type
 * @param title
 *            the title
 * @param value
 *            the value
 */
public static <T> void println(String title, final T value) {
	double bytes = MemoryHelper.sizeOf(value);
	double kb = NumberHelper.round(ByteUnit.BYTE.toKiB(bytes), 1);
	double mb = NumberHelper.round(ByteUnit.BYTE.toMiB(bytes), 1);
	//
	System.out.print(title);
	System.out.println(MessageFormat.format(MEMORY_PATTERN, bytes, kb, mb));
}
 
开发者ID:mixaceh,项目名称:openyu-commons,代码行数:19,代码来源:MemoryHelper.java


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