본문 바로가기
Computer/Etc

Empirical Evaluation of Algorithms

by hexists 2014. 8. 31.

알고리즘 스터디 중 기억하면 좋을 내용을 블로깅 해봅니다.

실제 개발시에 complexity를 고려하는 tip 입니다.

책은 Python algorithms(Magnus Lie Hetland) 입니다.


  • Empirical Evaluation of Algorithms(Practical Tips)
    • Tip1 : If possible, don't worry about it.
      • 먼저 구현해보고, 알고리즘이 적당한지 확인해라.
    • Tip2 : For timing things, use timeit.

      Python 2.7.5 (default, Mar  9 201422:15:05)
      [GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin
      Type "help""copyright""credits" or "license" for more information.
      >>> import timeit
      >>> timeit.timeit("x = 2 + 2")
      0.028252840042114258
      >>> timeit.timeit("x = 2 + 2")
      0.030072927474975586
       
      /* time a function */
      python -m timeit -s"import mymodule as m" "m.myfunction()"
    • Tip3 : To find bottlenecks, use a profiler.

      import cProfile
      cProfile.run("main()")
    • Tip4 : Plot your results.
    • Tip5 : Be careful when drawing conclusions based on timing comparisons.
      • 다른 임의적인 변수대신, 여러번 시간 측정을 통해 더 나은 구현을 선택하면 된다.
    • Tip6 : Be careful when drawing conclusions about asymptotics from experiments.
      • 여러번의 실험을 통해 asymptotics이 맞는지 검증하라.


'Computer > Etc' 카테고리의 다른 글

long-tail vs short head  (0) 2014.12.03
svn에서 다른 리비전간에 diff 하기  (0) 2014.11.25
mysqldump 이용하기  (0) 2014.11.24
hash의 충돌 해결법(collsion resolution in hash tables)  (0) 2014.11.16
hadoop distcp  (0) 2014.10.27