多进程多组建性能测试
来源:互联网 发布:智能手表软件下载 编辑:程序博客网 时间:2024/06/18 05:47
package org.cmm.thread;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
public class TwoThread {
public String processcall2() throws Exception{
// 设置线程数量
ExecutorService pool = Executors.newFixedThreadPool(500);
// 不限制线程数量
// ExecutorService pool = Executors.newCachedThreadPool();
// 任务数量
for (int i = 0; i < 25000000; i++) {
Runnable r = new Runnable() {
public void run() {
int x = 0;
for(int i = 0; i < 500; i++){
x += i;
if(x > 500){
x -= 500;
}
}
// System.out.println(x);
}
};
pool.execute(r);
}
pool.shutdown();
return "";
}
public static void main(String[] args) throws Exception {
// TODO Auto-generated method stub
Long loa = System.currentTimeMillis();
TwoThread ot = new TwoThread();
ot.processcall2();
Long lob = System.currentTimeMillis();
Long lo = lob - loa;
System.out.println(lo);
}
}
批处理:@echo off -jar (java文件打成JAR包的路径) pause
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
public class TwoThread {
public String processcall2() throws Exception{
// 设置线程数量
ExecutorService pool = Executors.newFixedThreadPool(500);
// 不限制线程数量
// ExecutorService pool = Executors.newCachedThreadPool();
// 任务数量
for (int i = 0; i < 25000000; i++) {
Runnable r = new Runnable() {
public void run() {
int x = 0;
for(int i = 0; i < 500; i++){
x += i;
if(x > 500){
x -= 500;
}
}
// System.out.println(x);
}
};
pool.execute(r);
}
pool.shutdown();
return "";
}
public static void main(String[] args) throws Exception {
// TODO Auto-generated method stub
Long loa = System.currentTimeMillis();
TwoThread ot = new TwoThread();
ot.processcall2();
Long lob = System.currentTimeMillis();
Long lo = lob - loa;
System.out.println(lo);
}
}
批处理:@echo off -jar (java文件打成JAR包的路径) pause
阅读全文
0 0
- 多进程多组建性能测试
- 性能测试实施(1)之团队组建
- 多进程多线程环境下的同步机制性能测试
- erlang多进程间通信的性能测试
- 用python做自动化测试--实现高性能测试工具(5) --多进程写log
- 进程间信号灯性能测试
- OpenWrt下基于Bird的AdHoc无线多跳网络组建与测试
- 组建好测试团队
- 如何组建测试团队
- 【软件测试】组建测试队伍
- golang多进程测试代码
- 多协议接口性能测试
- erlang 进程消息及ets性能测试
- 实用性测试团队的组建
- 如何组建软件测试团队
- 如何组建软件测试团队
- 组建多个工作组的对等网
- LINQ 多条件查询 where 条件组建
- Dialog常见问题(布局错误、黑边、圆角、异常)
- 数据库集群技术
- 数论知识
- XML特殊字符(如:换行)
- wait和waitpid
- 多进程多组建性能测试
- JavaScript之闭包
- 三.Hibernate 执行复杂的sql
- UVA-12265 Selling Land
- JS各种小知识点
- 警告: Setting property 'source' to 'org.eclipse.jst.jee.server:ASW' did not find a matching property
- PHP的语言结构和函数的区别
- 通过在Git Bash中使用命令行方法上传文件到GitLab的步骤
- 朴素贝叶斯解决天气问题