V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
chy373180
V2EX  ›  程序员

请教下, golang 写的 Fizz Buzz 怎么这么慢

  •  
  •   chy373180 · 2016-11-02 18:21:06 +08:00 · 1832 次点击
    这是一个创建于 2754 天前的主题,其中的信息可能已经有所发展或是发生改变。

    http://imgur.com/a/fDU6Y

    我的姿势问题?

    第 1 条附言  ·  2016-11-03 10:08:16 +08:00
    问了下 leetcode 的管理员,终于解开了疑问。
    Moreover, the distribution graph is more useful when to compare the solution to others which are of the same language.

    We treat languages differently when judge, perhaps your golang solution runs 100 times and python run only 10 times. That's possible.
    6 条回复    2016-11-03 09:35:48 +08:00
    holyghost
        1
    holyghost  
       2016-11-02 19:13:16 +08:00
    My Submissions for Fizz Buzz

    Submit Time Question Status Run Time Language

    2 weeks, 3 days ago Fizz Buzz Accepted 3 ms java

    2 weeks, 6 days ago Fizz Buzz Accepted 4 ms java

    姿势对不对,取决于你的代码是怎么写的。
    chy373180
        2
    chy373180  
    OP
       2016-11-02 19:25:45 +08:00
    @holyghost 不是啦 我的代码就是一般的写法,没什么问题。主要是想让大家看下平均水平,你看 python 的平均时间明显还要短于 golang ,跟我想的不大一样,觉得 golang 不是应该和 java c++一个量级么
    janxin
        3
    janxin  
       2016-11-02 19:41:36 +08:00
    我的答案只加一个字母就能从击败 20%到击败 80%,很多还是优化问题。算法重要的还是思路,优化基本是经验问题。
    reus
        4
    reus  
       2016-11-02 23:47:11 +08:00
    这只能说明这个测试不能反映出 go 的性能水平。
    JohnSmith
        5
    JohnSmith  
       2016-11-03 08:29:37 +08:00 via iPhone
    pporf
    loolac
        6
    loolac  
       2016-11-03 09:35:48 +08:00
    像是没有编译, go run 执行的 ~~~
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   2174 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 11:27 · PVG 19:27 · LAX 04:27 · JFK 07:27
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.