小编pen*_*sky的帖子

如何使用ember.js制作textarea autogrow?

我怎样才能使TextArea 自动增长与ember.js插件的工作?它似乎没有用Ember.TextArea.

我试过这个(coffeescript):

  App.TextField = Ember.TextArea.extend
    didInsertElement: ->
      opts =
        animate: false
        cloneClass: 'faketextarea'
      @$().autogrow(opts)
Run Code Online (Sandbox Code Playgroud)

autogrow ember.js

5
推荐指数
2
解决办法
1747
查看次数

如何优化 Haskell 中的数值积分性能(举例)

如何优化数值积分例程(与 C 相比)?

目前已经做了什么:

  1. 我用未装箱的向量替换了列表(显而易见)。
  2. 我应用了“Read World Haskell”一书中描述的分析技术http://book.realworldhaskell.org/read/profiling-and-optimization.html。我内联了一些琐碎的函数,并在各处插入了很多刘海。这带来了大约 10 倍的加速。
  3. 我重构了代码(即提取iterator函数)。这带来了 3 倍的加速。
  4. 我尝试用 Floats 替换多态签名,如这个问题 Optimizing numeric array Performance in Haskell 的答案。这几乎提高了 2 倍的速度。
  5. 我这样编译 cabal exec ghc -- Simul.hs -O2 -fforce-recomp -fllvm -Wall
  6. 更新按照 cchalmers 的建议,type Sample = (F, F)被替换为 data Sample = Sample {-# UNPACK #-} !F {-# UNPACK #-} !F

现在的性能几乎和C代码一样好。我们可以做得更好吗?

{-# LANGUAGE BangPatterns #-}

module Main
  where

import qualified Data.Vector.Unboxed as U
import qualified Data.Vector.Unboxed.Mutable as UM …
Run Code Online (Sandbox Code Playgroud)

optimization haskell numeric numerical-integration

5
推荐指数
0
解决办法
326
查看次数