ファイル情報

Rev. 2d5cda5e9dde331e37d58133b688a8b2c6295345
サイズ 1,973 バイト
日時 2017-09-03 14:40:39
作者 Daigo Moriwaki
ログメッセージ

Merge remote-tracking branch 'origin/master' into wdoor-stable

内容

  1. #! /usr/bin/ruby
  2. # $Id$
  3. #
  4. # Author:: Daigo Moriwaki
  5. # Homepage:: http://sourceforge.jp/projects/shogi-server/
  6. #
  7. #--
  8. # Copyright (C) 2011-2012 Daigo Moriwaki (daigo at debian dot org)
  9. #
  10. # This program is free software; you can redistribute it and/or modify
  11. # it under the terms of the GNU General Public License as published by
  12. # the Free Software Foundation; either version 2 of the License, or
  13. # (at your option) any later version.
  14. #
  15. # This program is distributed in the hope that it will be useful,
  16. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. # GNU General Public License for more details.
  19. #
  20. # You should have received a copy of the GNU General Public License
  21. # along with this program; if not, write to the Free Software
  22. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  23. #++
  24. #
  25. # == Synopsis
  26. #
  27. # shogi-server-profile is a wrapper of shogi-server to take profile, which
  28. # is only used by Shogi-server developers.
  29. #
  30. #
  31. # == Usage
  32. #
  33. # Same as shogi-server.
  34. #
  35. # == PREREQUIRE
  36. #
  37. # Sample Command lines that isntall prerequires will work on Debian.
  38. #
  39. # * {ruby-prof}[http://rubyforge.org/projects/ruby-prof/]
  40. #
  41. # $ sudo gem install ruby-prof
  42. #
  43. # == Run
  44. #
  45. # Same as shogi-server. It will result in a profile log file (calltree.log),
  46. # which can be read by KCacheGrind.
  47. #
  48. require 'ruby-prof'
  49. load 'shogi-server'
  50. if ($0 == __FILE__)
  51. STDOUT.sync = true
  52. STDERR.sync = true
  53. TCPSocket.do_not_reverse_lookup = true
  54. Thread.abort_on_exception = $DEBUG ? true : false
  55. begin
  56. result = RubyProf.profile do
  57. main
  58. end
  59. printer = RubyProf::CallTreePrinter.new(result)
  60. f = File.open("calltree.log", "w")
  61. printer.print(f, {})
  62. rescue Exception => ex
  63. if $logger
  64. log_error("main: #{ex.class}: #{ex.message}\n\t#{ex.backtrace[0]}")
  65. else
  66. $stderr.puts "main: #{ex.class}: #{ex.message}\n\t#{ex.backtrace[0]}"
  67. end
  68. end
  69. end
旧リポジトリブラウザで表示