星期四, 8月 24, 2017

Perl — Calculate timing difference in microseconds

Time::Piece has been in core since 5.10.


use Time::Piece;

sub str2time {
    my ($str) = @_;
    $str =~ s/(\.[0-9]+)?\z//;
    my $fraction = $1 || 0;
    return Time::Piece->strptime($str, '%Y-%m-%d %H:%M:%S')->epoch + $fraction;
}

my $t1 = str2time('2013-12-27 13:28:14.975952');
my $t2 = str2time('2013-12-27 13:28:16.345667');

printf "difference: %f\n", $t2 - $t1;


This can be used to analyze the trace for performance issue.

Note:

||                              if the left operand is true, the right operand is not even evaluated.
\z                             Match only at end of string
 ?                             Match 1 or 0 times
$var =~ s/A/B/       
把變數 $var 內的第一個A子字串整個代換成B子字串。特別注意第一部份(A)為RE, 但第二部分(B)僅為字串

http://irw.ncut.edu.tw/peterju/perl.html

$str =~ s/(\.[0-9]+)?\z//   => 表示將小數點後(含小數點)的部分用空字串取代, 也就是移除
$fraction = $1 || 0            => 表示若有找到小數點後的部分, 即把其值copy 給fraction, 不然就設為0




星期二, 8月 15, 2017

星期四, 8月 03, 2017

How to specify the path of the JVM core dump file

https://jazz.net/forum/questions/147686/is-it-possible-to-customize-the-java-core-and-heap-dump-paths-for-tomcat

http://www-01.ibm.com/support/docview.wss?uid=swg21255223

http://www-01.ibm.com/support/docview.wss?uid=swg21242497

Using dump agent to specify the path of the core file

example:

-Xdump:system:file="/path/core.%Y%m%d.%H%M%S.%pid.%seq.dmp"



How to install ComputerCraft mod for Minecraft

https://www.youtube.com/watch?v=pMrxzffJVs8


1. launch the Minecraft with the correct version
2. download and install corresponding forge version mod
3. download the corresponding ComputerCraft mod and put it into the mod subfolder

*** 不同版本的mod 可能無法被不同版本的Minecraft forge載入, 要搭配正確版本
例如: 1.7.10 的Minecraft 就要搭配同樣是1.7.10 的forge 和 ComputerCraft

若要切換不同版本, 也要記得移除mod目錄下的檔案, 換成正確版本的mod 檔案