V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX  ›  zjsxwc  ›  全部回复第 112 页 / 共 213 页
回复总数  4250
1 ... 108  109  110  111  112  113  114  115  116  117 ... 213  
2019-09-23 17:10:58 +08:00
回复了 zjsxwc 创建的主题 程序员 php7 怎么比 Java 还快?
@iminto

我用 golang,9000 并发时可以稳定在 0.35 秒左右
我用 c++写,9000 并发时可以在 0.5 秒左右 ( https://github.com/zjsxwc/xpng-test/blob/master/src/controller/MyController.hpp#L149
都是在一个数量级,差别不大
2019-09-23 15:06:18 +08:00
回复了 zjsxwc 创建的主题 程序员 php7 怎么比 Java 还快?
@Xusually

我系统是 Linux Deepin,apt install php 给我装了 7.0,就没有去换,汗
2019-09-23 13:45:32 +08:00
回复了 zjsxwc 创建的主题 程序员 php7 怎么比 Java 还快?
@reus 是的


不过最后测下来,感觉性能都差不多,和 io 有关把,我把 Linux ulimit 调到 10001 也是这个结果,再大我的电脑调不上去了,两者耗时还是差不多
2019-09-23 12:43:26 +08:00
回复了 zjsxwc 创建的主题 程序员 php7 怎么比 Java 还快?
我收回说的这句话,java 只是在第一次跑的时候会比 php 慢,之后多次访问后会快很多
2019-09-23 12:35:52 +08:00
回复了 zjsxwc 创建的主题 程序员 php7 怎么比 Java 还快?
@srx1982
@zgqq


我用 servlet 写了,跑在 Tomcat/9.0.22 上,耗时 0.259 秒,还是比 php 慢,要知道 php7 用的 server 是调试用的,上 php-fpm 会更快,


$ ab -n 1000 -c 1000 "http://localhost:8080/servlet-test-1.0-SNAPSHOT/x.png"
This is ApacheBench, Version 2.3 <$Revision: 1757674 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking localhost (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests


Server Software:
Server Hostname: localhost
Server Port: 8080

Document Path: /servlet-test-1.0-SNAPSHOT/x.png
Document Length: 70 bytes

Concurrency Level: 1000
Time taken for tests: 0.259 seconds
Complete requests: 1000
Failed requests: 0
Total transferred: 188000 bytes
HTML transferred: 70000 bytes
Requests per second: 3867.48 [#/sec] (mean)
Time per request: 258.566 [ms] (mean)
Time per request: 0.259 [ms] (mean, across all concurrent requests)
Transfer rate: 710.05 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 1 3.5 0 11
Processing: 1 24 13.6 21 74
Waiting: 1 22 12.5 19 72
Total: 3 26 15.3 21 83

Percentage of the requests served within a certain time (ms)
50% 21
66% 27
75% 32
80% 36
90% 51
95% 59
98% 67
99% 71
100% 83 (longest request)





代码:


import java.io.IOException;
import java.io.OutputStream;
import java.util.Base64;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
* Servlet implementation class XServlet
*/
public class XServlet extends HttpServlet {
private static final long serialVersionUID = 1L;

/**
* @see HttpServlet#HttpServlet()
*/
public XServlet() {
super();
// TODO Auto-generated constructor stub
}

/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setHeader("content-type","image/png");
String onepointpngBase64 = "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVQImWP4////fwAJ+wP9CNHoHgAAAABJRU5ErkJggg==";
OutputStream os = response.getOutputStream();
byte[] decodedValue = Base64.getDecoder().decode(onepointpngBase64);
os.write(decodedValue);
}

/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
doGet(request, response);
}

}
2019-09-23 08:40:57 +08:00
回复了 qiandongdong 创建的主题 问与答 如果躲过公司的电脑监控
画面截屏监控无解
2019-09-23 07:55:11 +08:00
回复了 codechaser 创建的主题 程序员 求解答一道算法题
@zjsxwc #12 原文:“动态规划,由于与数组顺序无关于是可以,定义 数组解为 A(XnYm) 其中 X、Y 为数组里数的值,n、m 为数 X、Y 分别出现的次数。于是状态转移方程为 A(Xn)=X*nA(XnYm)=max(X*n-m+A(Ym), Y*m-n+A(Xm))A(XnYmZa)=max(X*n-m-a+A(YmZa), Y*m-n-a+A(XmZa), Z*a-n-m+A(XnYm))...依次类推”


感觉复杂度还是 n^3 等大神解答吧

回复:
2019-09-23 07:47:15 +08:00
回复了 codechaser 创建的主题 程序员 求解答一道算法题
动态规划,
由于与数组顺序无关于是可以,定义 数组解为 A(XnYm) 其中 X、Y 为数组里数的值,n、m 为数 X、Y 分别出现的次数。

于是状态转移方程为
A(Xn)=X*n
A(XnYm)=max(X*n-m+A(Ym), Y*m-n+A(Xm))
A(XnYmZa)=max(X*n-m-a+A(YmZa), Y*m-n-a+A(XmZa), Z*a-n-mA(XnYm))
...
依次类推
2019-09-23 07:29:02 +08:00
回复了 codechaser 创建的主题 程序员 求解答一道算法题
动态规划,
由于与数组顺序无关于是可以,定义 数组解 A 为 X(n)+ Y(m)+... 其中 X、Y 为数组里数的值,n、m 为数 X、Y 分别出现的次数。

于是状态转移方程为
A(XnYm)=max(X*n-m+A(Ym), Y*m-n+A(Xm))
...
依次类推
2019-09-21 18:15:11 +08:00
回复了 racheljiaolee 创建的主题 职场话题 实习两周被劝退了……请问怎么避坑?
楼主这种实习还好吧,难道想去 startup 公司加班吗
2019-09-21 18:11:10 +08:00
回复了 freshgoose 创建的主题 问与答 你们或身边人现在还有买知识付费的产品吗?
微信读书续费,几块钱就能看书,爽的一批
2019-09-21 17:57:41 +08:00
回复了 ciaoly 创建的主题 问与答 学校给发的报道证有必要吗?
历史遗留问题吧,以前是包分配工作的,报到证也和档案一起走,现在大学生毕业有人不想工作等等,报到证得有个接受单位接受,如果不想工作的话也建议楼主找个公司挂靠下
2019-09-21 10:16:40 +08:00
回复了 Antidictator 创建的主题 程序员 你们也喜欢单方面删除好友吗?
垃圾微信我都懒得打开看,消息权限都不给它,删不删都一样
2019-09-21 07:39:38 +08:00
回复了 dp2px 创建的主题 Python Python 为什么现在这么火?百度指数高于其他很多
perl 是凉了吗,我还在玩 perl
2019-09-20 19:54:40 +08:00
回复了 Xianmua 创建的主题 PHP phpstudy 2016 年就被黑客植入后门
还是用 docker 靠谱
2019-09-20 18:16:24 +08:00
回复了 Shook 创建的主题 JavaScript 做一个 js 富文本编辑器,需要学习哪些知识点?
把用户对 html 文本的点击、输入等行为转化为新 html 文本

本质上和编译原理没有区别
2019-09-20 16:52:54 +08:00
回复了 xuroid 创建的主题 Android 在局域网内能做两个手机之间的直播么?
安卓的 airdroid 局域网分享摄像头也算视频吗?
1 ... 108  109  110  111  112  113  114  115  116  117 ... 213  
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   2035 人在线   最高记录 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 45ms · UTC 10:37 · PVG 18:37 · LAX 03:37 · JFK 06:37
Developed with CodeLauncher
♥ Do have faith in what you're doing.