Ruby China
  • 社区
  • 招聘
  • Wiki
  • 酷站
  • Gems
  • 注册
  • 登录
bhuztez
@bhuztez
高级会员
第 1569 位会员 / 2012-03-24

40 篇帖子 / 2614 条回帖
105 关注者
0 正在关注
0 收藏
未设置 GitHub 信息。
  • 概况
  • 话题
  • 回帖
  • 收藏
  • 正在关注
  • 关注者
  • 好像 Ruby 的性能问题始终是个大问题啊! at 2013年12月24日

    #86 楼 @luikore 不需要设计啊,Erlang 就自带静态分析工具的。

  • 好像 Ruby 的性能问题始终是个大问题啊! at 2013年12月24日

    #83 楼 @luikore Cython 基本等于不能分析,大部分时候你要把黄色干掉都需要标注类型,但是也没办法,这是 Python 语义决定的。

  • 好像 Ruby 的性能问题始终是个大问题啊! at 2013年12月24日

    #83 楼 @luikore 实现方法多老土都没关系,结果不可靠还拿出来吹就没意思了。

  • python 叛徒报道 at 2013年12月24日

    你这个叛逃方向不对啊 ...

  • 12306 曝重大漏洞 难挡 “刷票” at 2013年12月23日

    很抱歉!页面已丢失,但我们可以帮助他们找到亲人...

  • 一个美国人眼中的中国 (如果大家感兴趣的话) at 2013年12月22日

    #8 楼 @hpviewer

    但是现在同学历的年轻人的确比钱老更出色

    你怎么看出来的 ...

  • 一个美国人眼中的中国 (如果大家感兴趣的话) at 2013年12月22日

    #5 楼 @hpviewer 钱学森算什么?

  • 既然可以这样,为啥不能那样? at 2013年12月22日

    难道不是少了个 :

  • 12306 验证码简单识别 at 2013年12月22日

    #3 楼 @debbbbie 10% 人家都懒得理你啊。而且验证码难度越高对屌丝越不利吧 ...

    全搞成 recaptcha 那种奇葩的,人都三次错两次的,软件 tweak 得好识别率反而比人高 ..

  • 12306 验证码简单识别 at 2013年12月22日

    为啥提交给乌云啊 ...

    tweak 一下,应该能达到大约 50% 的正确率

  • Gitlab 是个好东西啊 at 2013年12月21日

    #16 楼 @hooopo format-patch已经是标准格式了,通过正常的邮件客户端都可以发的。不一定要用那个 git-send-email 脚本的

  • Gitlab 是个好东西啊 at 2013年12月21日

    #14 楼 @hooopo

    git help format-patch
    git help am
    git help apply
    
  • 好像 Ruby 的性能问题始终是个大问题啊! at 2013年12月21日

    #74 楼 @rasefon 这就是为什么我放弃 Ruby 转而自制语言了 ...

  • 好像 Ruby 的性能问题始终是个大问题啊! at 2013年12月21日

    #72 楼 @rasefon 写不出来说明很难啊

  • 好像 Ruby 的性能问题始终是个大问题啊! at 2013年12月21日

    #66 楼 @luikore

    Cython 还是略坑

    from libc.stdlib cimport malloc, free
    from cython import sizeof
    
    cdef pushDown(int *h, int pos, int n):
        cdef int j
    
        while 2 * pos + 1 < n:
            j = 2 * pos + 1
    
            if (j + 1 < n) and (h[j+1] > h[j]):
                j += 1
    
            if h[pos] >= h[j]:
                break
    
            h[pos], h[j] = h[j], h[pos]
            pos = j
    
    
    def heapsort(int size):
        cdef int i, n
        cdef int *heap = <int *>malloc(sizeof(int)*size)
    
        for i in range(size):
            heap[i] = i
    
        for i in range(size//2, -1, -1):
            pushDown(heap, i, size)
    
        for n in range(size-1, 0, -1):
            heap[0], heap[n] = heap[n], heap[0]
            pushDown(heap, 0, n)
    
        for i in range(size):
            assert i == heap[i], "Array not sorted"
    
        free(heap)
    
  • 好像 Ruby 的性能问题始终是个大问题啊! at 2013年12月21日

    #69 楼 @rasefon 只要不准看现有的 Ruby parser 是怎么写的。就算你用现成的工具生成也很难啊,你自己试一下就知道了么,除非你整天就是在写各种诡异的 parser 的

  • 好像 Ruby 的性能问题始终是个大问题啊! at 2013年12月21日

    #61 楼 @skandhas 重新算了下

    java 195 javascript 用 Mozilla 的引擎,速度上和 V8 应该区别不大

    js -j 641 js -a -m 1741

    在对比 Pypy 的速度

    可以认为 ruby 被多加了个 0

  • 好像 Ruby 的性能问题始终是个大问题啊! at 2013年12月21日

    #41 楼 @skandhas 好吧,我也觉得是 Python 少写了个 0

  • 好像 Ruby 的性能问题始终是个大问题啊! at 2013年12月21日

    #58 楼 @skandhas 此处用 pypy 有约 20 倍速度提升。这样来看,V8 好像也不算快么 ...

  • 好像 Ruby 的性能问题始终是个大问题啊! at 2013年12月21日

    #56 楼 @ShiningRay 快跑我的代码,看看结果如何

  • 好像 Ruby 的性能问题始终是个大问题啊! at 2013年12月21日

    #51 楼 @skandhas 也可能是 Python 用了 pypy ...

  • Gitlab 是个好东西啊 at 2013年12月21日

    #12 楼 @ruohanc 现在问题是没有 Github ...

  • 好像 Ruby 的性能问题始终是个大问题啊! at 2013年12月21日

    #48 楼 @ericguo

    Ruby 代码主要就是 a, b = b, a 这里手工展开所以才比 Python 2.7 快了,

    我去掉了个 0,实在太久了,等不起。

    $ python --version
    Python 2.7.5
    $ python3 --version
    Python 3.3.2
    $ pypy --version
    Python 2.7.3 (352c78d2e80f4a812ae1d8cdbe8c01a7f2e6fbc0, Aug 19 2013, 10:43:46)
    [PyPy 2.1.0 with GCC 4.8.1 20130603 (Red Hat 4.8.1-1)]
    $ ruby --version
    ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-linux]
    $ python heapsort.py 
    17.9021840096
    $ python3 heapsort.py 
    30.28932676600016
    $ pypy heapsort.py 
    0.749085903168
    $ ruby heapsort.rb 
     23.450000   0.010000  23.460000 ( 23.611715)
    

    代码改成一致的实现,不能因为一边有更快的写法就用更快的写法。

    from __future__ import division, unicode_literals, print_function
    
    import timeit
    
    try:
        range = xrange
    except NameError:
        pass
    
    
    def pushDown(h, pos, n):
        while 2 * pos + 1 < n:
            j = 2 * pos + 1
    
            if j + 1 < n and h[j+1] > h[j]:
                j += 1
    
            if h[pos] >= h[j]:
                break
    
            h[pos], h[j] = h[j], h[pos]
            pos = j
    
    def heapsort(size):
        heap = list(range(size))
    
        for i in range(size//2, -1, -1):
            pushDown(heap, i, size)
    
        for n in range(size-1, 0, -1):
            heap[0], heap[n] = heap[n], heap[0]
            pushDown(heap, 0, n)
    
        for i, e in enumerate(heap):
            assert i == e, "Array not sorted"
    
    if __name__ == "__main__":
        print(timeit.timeit("heapsort(1000000)", setup="from __main__ import heapsort", number=1))
    
    require 'benchmark'
    
    def push_down(heap, pos, n)
      while (2 * pos + 1) < n
        j = 2 * pos + 1
    
        if (j + 1 < n) and (heap[j + 1] > heap[j])
          j += 1
        end
    
        break unless heap[pos] < heap[j]
    
        heap[pos], heap[j] = heap[j], heap[pos]
    
        pos = j
      end
    end
    
    def heapsort(size)
      heap = (0...size).to_a
    
      (size / 2).downto(0) do |i|
        push_down heap, i, size
      end
    
      (size - 1).downto(1) do |n|
        heap[0], heap[n] = heap[n], heap[0]
    
        push_down heap, 0, n
      end
    
      raise "Array not sorted" unless heap.each.with_index.all? { |element, index| element == index }
    end
    
    puts Benchmark.measure { heapsort 1000000 }
    
  • 好像 Ruby 的性能问题始终是个大问题啊! at 2013年12月21日

    #44 楼 @skandhas 很可能是 Ruby 出奇的慢吧

  • 今天发现一个以前没有注意到的好用的 ruby 语法,分享一下 at 2013年12月21日

    #9 楼 @linjunhalida

    Ruby 学 Smalltalk,要让控制流以库而不是关键字的形式提供,才用了类似抛错的机制。你可以认为其实 break/return 什么的也是会 throw 的。

    Rust,不像 Ruby 有 block 和 lambda 两种不同的语义。Rust 只有 lambda,并且是通过不同的返回值来实现不同的控制流,最后通过编译期对 lambda 的统一优化来消除额外的运行期开销。

    参考 http://lucumr.pocoo.org/2012/10/18/such-a-little-thing/

  • 今天发现一个以前没有注意到的好用的 ruby 语法,分享一下 at 2013年12月21日

    这个就是 Ruby 没搞对的地方,这个就是 Rust 搞对的地方 ...

  • Gitlab 是个好东西啊 at 2013年12月21日

    #8 楼 @ruohanc 邮件列表一点都不小众。无论是 git 还是 hg 或者别的什么 SCM,都是原生支持邮件的,就是为了能让你通过邮件列表完成工作。

  • 好像 Ruby 的性能问题始终是个大问题啊! at 2013年12月21日

    #41 楼 @skandhas 可能是因为在 Windows 上测的 ...

  • 好像 Ruby 的性能问题始终是个大问题啊! at 2013年12月21日

    #36 楼 @skandhas 对啊,之前的 jjyr benchmark 也是类似的结果 http://ruby-china.org/topics/12688

    很奇怪啊,几乎一样的实现 (Python 只是没有 direct threading),Ruby 1.9/2.0能快很多

  • Gitlab 是个好东西啊 at 2013年12月21日

    善用邮件列表就好了,真的

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