ヘビィ・SMD! -93ページ目

ヘビィ・SMD!

そんな・・・バナナ!!
1. 甘え度+10 恐れ度+10 寿命-1週間
2. 甘え度+10 恐れ度-10
3. 甘え度-10 恐れ度-10 寿命+1週間

さて。
ゲットしたぜ。
Feeder / Renegades
発売が30日だけど29日の昼には入荷しています、
という店員さんの助言を受けていたので
若干早いかもしれないという不安はあったが、
13:30に新宿タワレコに特攻!無事ゲットできました。

れっつごーsmd-2010062914200000.jpg


で、当のFeederさんはと言うと、
今日代官山でライブするんだよね。
残念ながら僕はチケットが取れずじまい、、
行かれる方は存分に楽しんできて下さい。
だ け ど
明日、インストアイベント@渋谷タワレコには参加さ!
タワレコで予約した人にチケットを渡す方式で入場できると。
僕は新宿店でチケットもらったが、番号が「25」。
かなり早い時間に行ったつもりなのに、先に24人の猛者がいたということか・・・

ということで。
今日の夜は家か会社でRenegades聴きながらサッカーを観てやるさ!
明日は18:30に会社を早退して渋谷に行くから早起きもしなきゃ。
ダンスの練習に三茶にも行かなきゃ。
多忙だな!おれ!


そうそう。
タワレコから会社に戻る途中、新宿駅の東南口のところでパフォーマーさんがいた。
静止状態でした。
ずっと静止状態でした。
暫く見ていると、こちらに対しにこやかな笑顔をくれました。

そしてまた、
静止状態でした。

$れっつごーsmd-P1000339.jpg
どうも。
「将来の夢はジェントルマンです」
でお馴染みの
s
m
d
です。

会社に来たのはいいものの。
別の案件のリリース関係で
日曜なのに会社は騒々しいです。

集中できん。

ということでもう帰ります。
クリーニングに出していたシャツとかも回収しなくては。

そうそう。
さっき、うちの会社の中で、めっちゃ偉い人に
こんなんもらいました。

$れっつごーsmd-2010062717340000.jpg

どういう経緯で僕に手渡したのかはわからないけど、
記念にもらっておきました。

今は相手がいないので使わないけどね!
仕事で利用する機会があり調べたんだが、javaのbase64の立ち位置って微妙のようだ。
いろんなパッケージに内包されていて、どれを使うのが最善なのか。。

そんななか、色々と比較/評価しているサイトを発見。
http://trasis.jp/blog/lab/2008/03/javabase64.html

ほう。
javamailがいいのか。
commons-codecもそこそこいいじゃないか。

じゃあ、自分でもやってみよう(この二つだけね)。
ということでサンプルを作ってみた。
デバッグしやすいように、コードは小分けにして。
jdk1.5.12の環境で、
commons-codec-1.4-bin.zipからcommons-codec-1.4.jarを。
javamail-1.4.3.zipからmailapi.jarを。
ソースは以下の感じ。


public class JavaBase64Test {
public static void main(String[] args) throws Exception {
// 入力元文字列。好きなバンドの歌詞である。
String orgStr = "I'm going out for a while So I can get high with my friends";
// 開始時間ミリ秒
long timeStart = System.currentTimeMillis();
// base64エンコードにより文字列取得
String encStr = null;
for (int i = 0; i < 1000000; i++) {
encStr = getEncode_JavaMail(orgStr);
}
// エンコード完了時間ミリ秒
long timeEncode = System.currentTimeMillis();
// base64デコードにより文字列取得
String decStr = null;
for (int i = 0; i < 1000000; i++) {
decStr = getDecode_JavaMail(encStr);
}
// デコード完了時間ミリ秒
long timeDecode = System.currentTimeMillis();

// 結果表示
System.out.println("orgStr : " + orgStr);
System.out.println("encStr : " + encStr);
System.out.println("decStr : " + decStr);
System.out.println("Encode Time (ms) : " + (timeEncode - timeStart));
System.out.println("Decode Time (ms) : " + (timeDecode - timeEncode));
}

public static String getEncode_Commons(String strInput) throws Exception {
byte[] bInput = strInput.getBytes();
byte[] bEncode = org.apache.commons.codec.binary.Base64.encodeBase64(bInput);
String strEncode = new String(bEncode);
return strEncode;
}

public static String getDecode_Commons(String strInput) throws Exception {
byte[] bInput = strInput.getBytes();
byte[] bDecode = org.apache.commons.codec.binary.Base64.decodeBase64(bInput);
String strDecode = new String(bDecode);
return strDecode;
}

public static String getEncode_JavaMail(String strInput) throws Exception {
byte[] bInput = strInput.getBytes();
byte[] bEncode = com.sun.mail.util.BASE64EncoderStream.encode(bInput);
String strEncode = new String(bEncode);
return strEncode;
}

public static String getDecode_JavaMail(String strInput) throws Exception {
byte[] bInput = strInput.getBytes();
byte[] bDecode = com.sun.mail.util.BASE64DecoderStream.decode(bInput);
String strDecode = new String(bDecode);
return strDecode;
}
}


で、エンコードとデコードを100万回ずつ実行した結果はと言うと、
commons-codec
Encode Time (ms) : 7812
Decode Time (ms) : 6422
javamail
Encode Time (ms) : 4500
Decode Time (ms) : 4734
うーん。
確かにjavamailの方が速いね。
だ・け・ど。
javamailのjarに入ってるものを利用するよりはcommons-codecの方を利用したほうが
なんとなくだけど、すっきりするので(ただの好み)僕はcommons-codecを利用しています。

ちなみに、エンコード/デコードの各メソッドはあんな細かく分ける必要なんかなくて、


public static String getEncode_Commons(String strInput) throws Exception {
return new String(org.apache.commons.codec.binary.Base64.encodeBase64(strInput.getBytes()));
}

public static String getDecode_Commons(String strInput) throws Exception {
return new String(org.apache.commons.codec.binary.Base64.decodeBase64(strInput.getBytes()));
}

public static String getEncode_JavaMail(String strInput) throws Exception {
return new String(com.sun.mail.util.BASE64EncoderStream.encode(strInput.getBytes()));
}

public static String getDecode_JavaMail(String strInput) throws Exception {
return new String(com.sun.mail.util.BASE64DecoderStream.decode(strInput.getBytes()));
}


と1行ですっきり書けたりします。