SlideShare uma empresa Scribd logo
1 de 21
Kansai.pm #16
id:karupanerura
Time::Moment
+ Time::Strptime
= 💪
About me
• Kenta SATO (id:karupanerura)
• Perl/Go/Swift/Kotlin/Java/Crystal/C99/etc..
• Gotanda.pm Author
• Senior Engineer at Mobile Factory, Inc.
• WebApp/iOS/Android/Operation/etc..
日時処理
日時処理
• 日付や時刻に関する処理
• 単純な計算にならない
• タイムゾーン
• うるう年/うるう秒
• 月またぎ
タイムゾーン
• 時差を管理する概念
• UTC(世界標準時)からの時差=>オフセット
• 地域ごとに決まっている
• (現在の)日本だったら全域JST-9(Asia/Tokyo)
• サマータイムもタイムゾーンで管理
Yokohama.pm #10
http://www.slideshare.net/karupanerura/yokohamapm-10
Time::Moment
Time::Moment
• 日時処理モジュール
• シンプル
• 高速
• 不変性
シンプル
• 固定オフセットのみをサポート
• サマータイムなどは考慮しない
• 秒ベースで計算
高速
• 基本的に全ての処理がCで書かれている
• c-dt というCライブラリのPerlバインディング
不変性
• 同じインスタンスは必ず同一の日時を指す
• 副作用が最小限になる
どれくらい速いか
=> DEMO
弱点
Time::Momentの弱点
• 任意フォーマットの日付のparseが不可能
• from_stringはあるがフォーマットは固定
• システムのタイムゾーン/ロケールに依存
Time::Momentの弱点
• 任意フォーマットの日付のparseが不可能
• from_stringはあるがフォーマットは固定
• システムのタイムゾーン/ロケールに依存
↑ Time::Strptime
↑DateTimeX::Moment
Time::Strptime
Time::Strptime
• 拙作の汎用のstrptime実装
• Pure Perlで動く
• 高速
• 昨日、1.00が出ました
YAPC::EU 2015http://www.slideshare.net/karupanerura/optimize-perl5-code-for-perfomance-freaks
Time::Momentと組み合わせる
• Time::Momentでstrptimeできるようになる!
• 弱点がひとつ解決!
DEMO
まとめ
• Time::Momentは良い
• Time::Strptimeと組み合わせると最強
• 💪 💪 💪 💪 💪 💪 💪 💪 💪 💪 💪 💪 💪 💪 💪

Mais conteúdo relacionado

Mais de karupanerura

モジュール開発におけるぼくの試行錯誤
モジュール開発におけるぼくの試行錯誤モジュール開発におけるぼくの試行錯誤
モジュール開発におけるぼくの試行錯誤
karupanerura
 
mysqlcasual6-next-key-lock
mysqlcasual6-next-key-lockmysqlcasual6-next-key-lock
mysqlcasual6-next-key-lock
karupanerura
 

Mais de karupanerura (20)

Perl5 VS JSON
Perl5 VS JSONPerl5 VS JSON
Perl5 VS JSON
 
コンテキストと仲良く
コンテキストと仲良くコンテキストと仲良く
コンテキストと仲良く
 
The plan of Aniki 2.0
The plan of Aniki 2.0The plan of Aniki 2.0
The plan of Aniki 2.0
 
Aniki::Internal
Aniki::InternalAniki::Internal
Aniki::Internal
 
The Crystal language *recently* update
The Crystal language *recently* updateThe Crystal language *recently* update
The Crystal language *recently* update
 
KOWAZA for mackerel
KOWAZA for mackerelKOWAZA for mackerel
KOWAZA for mackerel
 
Optimize perl5 code for perfomance freaks
Optimize perl5 code for perfomance freaksOptimize perl5 code for perfomance freaks
Optimize perl5 code for perfomance freaks
 
Technology for reduce of mistakes - うっかりをなくす技術
Technology for reduce of mistakes - うっかりをなくす技術Technology for reduce of mistakes - うっかりをなくす技術
Technology for reduce of mistakes - うっかりをなくす技術
 
router-simple.cr
router-simple.crrouter-simple.cr
router-simple.cr
 
Why we use mruby with Perl5?
Why we use mruby with Perl5?Why we use mruby with Perl5?
Why we use mruby with Perl5?
 
はかたの塩
はかたの塩はかたの塩
はかたの塩
 
Gotanda.pmの紹介
Gotanda.pmの紹介Gotanda.pmの紹介
Gotanda.pmの紹介
 
すいすいSwift
すいすいSwiftすいすいSwift
すいすいSwift
 
Perlにおけるclass実装パターン
Perlにおけるclass実装パターンPerlにおけるclass実装パターン
Perlにおけるclass実装パターン
 
モジュール開発におけるぼくの試行錯誤
モジュール開発におけるぼくの試行錯誤モジュール開発におけるぼくの試行錯誤
モジュール開発におけるぼくの試行錯誤
 
Aniki - The ORM as our great brother.
Aniki - The ORM as our great brother.Aniki - The ORM as our great brother.
Aniki - The ORM as our great brother.
 
Perl5 meta programming
Perl5 meta programmingPerl5 meta programming
Perl5 meta programming
 
mysqlcasual6-next-key-lock
mysqlcasual6-next-key-lockmysqlcasual6-next-key-lock
mysqlcasual6-next-key-lock
 
dwangocpp1-lt
dwangocpp1-ltdwangocpp1-lt
dwangocpp1-lt
 
engineer-life
engineer-lifeengineer-life
engineer-life
 

Último

Último (11)

LoRaWAN スマート距離検出デバイスDS20L日本語マニュアル
LoRaWAN スマート距離検出デバイスDS20L日本語マニュアルLoRaWAN スマート距離検出デバイスDS20L日本語マニュアル
LoRaWAN スマート距離検出デバイスDS20L日本語マニュアル
 
LoRaWANスマート距離検出センサー DS20L カタログ LiDARデバイス
LoRaWANスマート距離検出センサー  DS20L  カタログ  LiDARデバイスLoRaWANスマート距離検出センサー  DS20L  カタログ  LiDARデバイス
LoRaWANスマート距離検出センサー DS20L カタログ LiDARデバイス
 
新人研修 後半 2024/04/26の勉強会で発表されたものです。
新人研修 後半        2024/04/26の勉強会で発表されたものです。新人研修 後半        2024/04/26の勉強会で発表されたものです。
新人研修 後半 2024/04/26の勉強会で発表されたものです。
 
Amazon SES を勉強してみる その32024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その32024/04/26の勉強会で発表されたものです。Amazon SES を勉強してみる その32024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その32024/04/26の勉強会で発表されたものです。
 
論文紹介:Selective Structured State-Spaces for Long-Form Video Understanding
論文紹介:Selective Structured State-Spaces for Long-Form Video Understanding論文紹介:Selective Structured State-Spaces for Long-Form Video Understanding
論文紹介:Selective Structured State-Spaces for Long-Form Video Understanding
 
Observabilityは従来型の監視と何が違うのか(キンドリルジャパン社内勉強会:2022年10月27日発表)
Observabilityは従来型の監視と何が違うのか(キンドリルジャパン社内勉強会:2022年10月27日発表)Observabilityは従来型の監視と何が違うのか(キンドリルジャパン社内勉強会:2022年10月27日発表)
Observabilityは従来型の監視と何が違うのか(キンドリルジャパン社内勉強会:2022年10月27日発表)
 
論文紹介: The Surprising Effectiveness of PPO in Cooperative Multi-Agent Games
論文紹介: The Surprising Effectiveness of PPO in Cooperative Multi-Agent Games論文紹介: The Surprising Effectiveness of PPO in Cooperative Multi-Agent Games
論文紹介: The Surprising Effectiveness of PPO in Cooperative Multi-Agent Games
 
NewSQLの可用性構成パターン(OCHaCafe Season 8 #4 発表資料)
NewSQLの可用性構成パターン(OCHaCafe Season 8 #4 発表資料)NewSQLの可用性構成パターン(OCHaCafe Season 8 #4 発表資料)
NewSQLの可用性構成パターン(OCHaCafe Season 8 #4 発表資料)
 
Amazon SES を勉強してみる その22024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その22024/04/26の勉強会で発表されたものです。Amazon SES を勉強してみる その22024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その22024/04/26の勉強会で発表されたものです。
 
業務で生成AIを活用したい人のための生成AI入門講座(社外公開版:キンドリルジャパン社内勉強会:2024年4月発表)
業務で生成AIを活用したい人のための生成AI入門講座(社外公開版:キンドリルジャパン社内勉強会:2024年4月発表)業務で生成AIを活用したい人のための生成AI入門講座(社外公開版:キンドリルジャパン社内勉強会:2024年4月発表)
業務で生成AIを活用したい人のための生成AI入門講座(社外公開版:キンドリルジャパン社内勉強会:2024年4月発表)
 
論文紹介:Video-GroundingDINO: Towards Open-Vocabulary Spatio-Temporal Video Groun...
論文紹介:Video-GroundingDINO: Towards Open-Vocabulary Spatio-Temporal Video Groun...論文紹介:Video-GroundingDINO: Towards Open-Vocabulary Spatio-Temporal Video Groun...
論文紹介:Video-GroundingDINO: Towards Open-Vocabulary Spatio-Temporal Video Groun...
 

TIme::Moment+Time::Strptime=