Ruby China
  • 社区
  • 招聘
  • Wiki
  • 酷站
  • Gems
  • 注册
  • 登录
Rei
@Rei
管理员
第 1 位会员 / 2011-10-28

[email protected]
深圳
185 篇帖子 / 9143 条回帖
728 关注者
0 正在关注
11 收藏
中下水平 Rails 程序员
打赏作者
GitHub Public Repos
  • writings 941

    [Closed] Source code of writings.io

  • alipay 732

    Unofficial alipay ruby gem

  • code_campo 291

    [Closed] Source code of http://codecampo.com

  • asciidoctor-pdf-cjk-ka... 101

    **no longer maintained**

  • asciidoctor-htmlbook 31

    Asciidoctor HTMLBook is an Asciidoctor backend for converting AsciiDoc documents to HTMLBook docu...

  • material-ui 17

  • htmlrenderer 12

  • rich-text-editor 12

  • rails-chatgpt-demo 8

  • rails-app 7

    A Rails project template lets me start new projects quickly.

More on GitHub
  • 概况
  • 话题
  • 回帖
  • 收藏
  • 正在关注
  • 关注者
  • Rails 有那么慢吗 at 2012年11月24日

    测试了一下,用 passenger start -p 4000 -e production --max-pool-size 100 --min-instances 10 启动

    ab -c 10 -n 100 http://localhost:4000/

    按原文的代码

    Server Software:        nginx/1.2.3
    Server Hostname:        localhost
    Server Port:            4000
    
    Document Path:          /
    Document Length:        512451 bytes
    
    Concurrency Level:      10
    Time taken for tests:   21.563 seconds
    Complete requests:      100
    Failed requests:        0
    Write errors:           0
    Total transferred:      51319400 bytes
    HTML transferred:       51245100 bytes
    Requests per second:    4.64 [#/sec] (mean)
    Time per request:       2156.277 [ms] (mean)
    Time per request:       215.628 [ms] (mean, across all concurrent requests)
    Transfer rate:          2324.22 [Kbytes/sec] received
    
    Connection Times (ms)
                  min  mean[+/-sd] median   max
    Connect:        0    0   0.1      0       0
    Processing:  1273 2107 311.6   2128    2994
    Waiting:     1273 2106 311.6   2128    2994
    Total:       1273 2107 311.7   2128    2994
    
    Percentage of the requests served within a certain time (ms)
      50%   2128
      66%   2290
      75%   2336
      80%   2362
      90%   2460
      95%   2544
      98%   2747
      99%   2994
     100%   2994 (longest request)
    

    把 view 里面的循环移到 controller

    class MainController < ApplicationController
      def index
        sleep(0.2)
        @content = 128000.times.map{rand(8999)+1000}.join
      end
    end
    
    <%= @content %>
    

    结果有了不少改善

    Server Software:        nginx/1.2.3
    Server Hostname:        localhost
    Server Port:            4000
    
    Document Path:          /
    Document Length:        512451 bytes
    
    Concurrency Level:      10
    Time taken for tests:   4.817 seconds
    Complete requests:      100
    Failed requests:        0
    Write errors:           0
    Total transferred:      51319400 bytes
    HTML transferred:       51245100 bytes
    Requests per second:    20.76 [#/sec] (mean)
    Time per request:       481.690 [ms] (mean)
    Time per request:       48.169 [ms] (mean, across all concurrent requests)
    Transfer rate:          10404.33 [Kbytes/sec] received
    
    Connection Times (ms)
                  min  mean[+/-sd] median   max
    Connect:        0    0   0.1      0       0
    Processing:   363  466  97.4    442     768
    Waiting:      362  465  97.2    442     768
    Total:        363  466  97.4    442     768
    
    Percentage of the requests served within a certain time (ms)
      50%    442
      66%    480
      75%    502
      80%    513
      90%    593
      95%    735
      98%    767
      99%    768
     100%    768 (longest request)
    

    结论是

    1. View 里的循环多花了很多时间
    2. 他的电脑没我的快
  • 应届毕业生没有三方协议会怎么样? at 2012年11月24日

    #26 楼 @QueXuQ 我就普通毕业的。因为没想好要做什么,毕业就在家想了半年。

  • ruby 有定时器吗 (scheduler)? at 2012年11月24日

    用系统的 https://github.com/javan/whenever

  • 应届毕业生没有三方协议会怎么样? at 2012年11月23日

    #22 楼 @DoIT 写代码,思考人生。

  • 应届毕业生没有三方协议会怎么样? at 2012年11月23日

    #15 楼 @QueXuQ 毕业后家里蹲了半年。

  • 应届毕业生没有三方协议会怎么样? at 2012年11月23日

    我是毕业半年后才找工作,没提三方协议。

  • 请问各位是怎么样才本地测试 production 模式的呢? at 2012年11月22日

    #11 楼 @QueXuQ 这真诡异了,production 和 development 是用同样的数据库吗?database.yml 里面有设置编码的项,数据库也有几个编码设置,都统一 utf-8。

  • 请问各位是怎么样才本地测试 production 模式的呢? at 2012年11月22日

    #9 楼 @QueXuQ 顺着 javascript 的 link 看能不能打开,在控制台调用 js 里定义的 function 看能不能调用。

    还有一个可能是浏览器缓存,chrome 的控制台右下角配置里面有 disable cache 选项。

  • 请问各位是怎么样才本地测试 production 模式的呢? at 2012年11月22日

    #6 楼 @QueXuQ 没有用 git?

  • 请问各位是怎么样才本地测试 production 模式的呢? at 2012年11月22日

    #6 楼 @QueXuQ 本机几乎不跑生产模式。除非发现了开发模式正常,生产模式出 bug 了才会去调试生产模式。

  • 请问各位是怎么样才本地测试 production 模式的呢? at 2012年11月22日

    本机,开发模式 -> 测试服务器,生产模式,5 分钟自动部署 -> 线上服务器,生产模式,手动部署

  • 什么时候用 form_for 什么时候用 form_tag 啊? at 2012年11月21日

    有对应 Model 的时候用 form_for,没有就用 form_tag,比如搜索框一般没有对应 Model。

  • 如何在 linux 开发桌面小部件 at 2012年11月20日

    查了一下,gnome 原生没带桌面小部件的机制,还得额外装应用 http://askubuntu.com/questions/4683/does-gnome-support-desktop-widgets

    桌面开发选择余地其实不多,先看要对应什么桌面,桌面提供了什么编程环境,然后这个编程环境有什么语言绑定。

    我曾经想用 Ruby 写 kde plasma 的部件,发现 Ruby 绑定不完善,后来不了了之了。

  • 如何在 linux 开发桌面小部件 at 2012年11月20日

    还要看哪个桌面环境。

  • "不要叫自己程序员" - 职业起步同学的建议 at 2012年11月20日

    赞成。

  • 能否设立一个节点:紧急问题 at 2012年11月19日

    怎么没人回答,没人懂吗?!

  • 上海归来,写点感受,及读音的重要性 at 2012年11月19日

    看来要多看国外视频,不然连读错了都不知道。我一直读 catch。

  • BritRuby Conf 因为被职责性别种族歧视被取消了 at 2012年11月19日

    是不是明年要预备 showboy 了。

  • 这两天给好几个人买了这个马克杯…… at 2012年11月18日

    马桶……

  • 一群 Ruby 社区的人占领了旁边的如家酒店 at 2012年11月16日

    如果这时候……

  • 怎么在 rails 的 update_attribute 时能做 validates 呢? at 2012年11月16日

    #6 楼 @AlphaLiu 那么,为什么更新 email 的时候 password 校验会通不过?

  • 怎么在 rails 的 update_attribute 时能做 validates 呢? at 2012年11月16日

    #4 楼 @AlphaLiu 如果 password_confirmation 有可能为空,那么应该打个补丁把 secure_password 方法覆盖掉,去掉 presence 校验。

  • 上一页
  • 1
  • 2
  • …
  • 217
  • 218
  • 219
  • 220
  • 221
  • …
  • 273
  • 274
  • 下一页
关于 / RubyConf / Ruby 镜像 / RubyGems 镜像 / 活跃会员 / 组织 / API / 贡献者
由众多爱好者共同维护的 Ruby 中文社区,本站使用 Homeland 构建,并采用 Docker 部署。
服务器由 赞助 CDN 由 赞助
iOS 客户端 / Android 客户端 简体中文 / English