Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Inside of Time::Strptime
Search
karupanerura
July 05, 2018
Technology
1.8k
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Inside of Time::Strptime
Shibuya.pm #18 LT
karupanerura
July 05, 2018
More Decks by karupanerura
See All by karupanerura
音を出したい
karupanerura
0
120
Perl Meets \w+ あるいは開発を支えるPerl活用の実例集
karupanerura
0
100
log
karupanerura
1
120
Use Perl as Better Shell Script
karupanerura
0
980
GoでParserを書く
karupanerura
4
1.1k
マイ隙間家具OSSたちのご紹介
karupanerura
2
320
Mustache Template 話 2024
karupanerura
0
82
1つの言語を原点に色々な言語を学ぶということ
karupanerura
4
4.6k
Javaの実装をPerlでテストする
karupanerura
0
1.5k
Other Decks in Technology
See All in Technology
Webの常識が通じないHTMLメールのダークモード
teamlab
PRO
0
130
ストレスなくAIと付き合いたい!こんなときどうしてる?
namiki64
3
600
Running Kotlin + Quarkus with Lambda
nealle
1
3.9k
Claude の新機能を、 出た日に触って社内に届けるまで
rfdnxbro
1
190
10年後、Engineering 行為を剥奪されるとして、わたしたちは、どう、何を創ればいいだろうか。 / If Engineering Is Taken Away in 10 Years, How and What Should We Create?
bitkey
PRO
1
200
専門領域のAIをどう評価するか
bengo4com
2
280
Active Record Connection Adaptersにおける長年の課題に再び取り組む
yahonda
0
200
しろおびから始める!ログ活用の第一歩
shumei_ito
0
950
パスキーの自動テストはどこまでいけるのか
teamlab
PRO
0
270
Refining Active Record
shugo
0
160
DBについての基礎説明(MySQL編) - コロプラ 2026年度 新卒研修
colopl
0
120
20261017福岡devIO 「AIは"良いダッシュボード"を作れるか?
jtakeda
0
180
Featured
See All Featured
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
Navigating Team Friction
lara
192
16k
Balancing Empowerment & Direction
lara
6
1.3k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
35
2.9k
Jamie Indigo - Trashchat’s Guide to Black Boxes: Technical SEO Tactics for LLMs
techseoconnect
PRO
0
710
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
56
3.5k
Intergalactic Javascript Robots from Outer Space
tanoku
273
28k
Building an army of robots
kneath
307
47k
Unlocking the hidden potential of vector embeddings in international SEO
frankvandijk
0
1k
BBQ
matthewcrist
90
10k
Being A Developer After 40
akosma
92
590k
Statistics for Hackers
jakevdp
799
230k
Transcript
Inside of Time::Strptime id:karupanerura Shibuya.pm #18 LT
Time::Strptime
use Time::Strptime qw/strptime/; # function my ($epoch_f, $offset_f) = strptime('%Y-%m-%d
%H:%M:%S', '2014-01-01 00:00:00'); # OO style my $fmt = Time::Strptime::Format->new('%Y-%m-%d %H:%M:%S'); my ($epoch_o, $offset_o) = $fmt->parse('2014-01-01 00:00:00'); Time::Strptime
Time::Strptime • strptime(3) ͷ Pure Perl ࣮ • Time::MomentͰҙϑΥʔϚοτͷύʔε͕ Ͱ͖ͳ͔ͬͨͷͰ࡞ͬͨ
• ߴ
Pure Perlͳͷʹߴʁʁʁ
ϕϯνϚʔΫ
݅ • OS X High Sierra • Perl 5.28.0 •
Time::Local: 1.28 • Time::Moment: 0.44 • Time::Piece: 1.3204 • Time::Strptime: 1.03
݅ • %Y-%m-%d %H:%M:%S Ͱparse͢Δ • epochͱoffsetΛऔಘ • ParserΩϟογϡͯ͠ྑ͍(cachedͱ໌ه) •
GMTͰ࣮ߦ(offsetܭࢉͷ࠷దԽՄೳ)
Benchmark: running pt, tm, tp, tp(cached), ts(cached) for at least
10 CPU seconds... pt: 11 wallclock secs (10.41 usr + 0.01 sys = 10.42 CPU) @ 297345.59/s (n=3098341) tm: 10 wallclock secs (10.17 usr + 0.01 sys = 10.18 CPU) @ 2481673.28/s (n=25263434) tp: 10 wallclock secs (10.52 usr + 0.01 sys = 10.53 CPU) @ 56390.98/s (n=593797) tp(cached): 11 wallclock secs (10.53 usr + 0.01 sys = 10.54 CPU) @ 80838.24/s (n=852035) ts(cached): 11 wallclock secs (10.60 usr + 0.01 sys = 10.61 CPU) @ 267686.15/s (n=2840150) Rate tp tp(cached) ts(cached) pt ™ tp 56391/s -- -30% -79% -81% -98% tp(cached) 80838/s 43% -- -70% -73% -97% ts(cached) 267686/s 375% 231% -- -10% -89% pt 297346/s 427% 268% 11% -- -88% tm 2481673/s 4301% 2970% 827% 735% -- tp=Time::Piece(XS) ts=Time::Strptime(PP) pt=POSIX::strptime tm=Time::Moment(XS)
݁Ռ • Time::Piece(cached)ʹରͯ͠231%ߴ • POSIX::strptimeʹରͯ͠10% • ※DateTimeൺֱͷܻ͕ҧ͏ͷͰআ֎ͯ͠Δ • ͓ͦ͗͢Δ
ͳ͍ͥʁ
Ξϓϩʔν • ࠷దԽͨ͠ίʔυΛੜͯ͠Ωϟογϡ • ذͱϝϞϦΞϩέʔγϣϯΛ࠷খԽ • ಉ͡Ξϓϩʔνͷ࣮ • Text::MicroTemplate •
Apache::LogFormat::Compiler
ੜίʔυྫ my ($year, $month, $day, $hour24, $minute, $second, $offset, $epoch);
$offset = 0; sub { ($year, $month, $day, $hour24, $minute, $second) = $_[0] =~ m{\A([0-9]{4})\-(0[1-9]|1[0-2])\-(0[1-9]|[12] [0-9]|3[01])T([01][0-9]|2[0-3])\:([0-5][0-9])\:([0-5][0-9]| 60)\z}mo or Carp::croak 'cannot parse datetime. text: "'. $_[0].'", format: '."\"%FT%T\""; $epoch = timegm_nocheck($second, $minute, $hour24, $day, $month - 1, $year); $offset = $time_zone->offset($epoch); $epoch -= $offset; ($epoch, $offset); };
͜ΕΛText Evalͯ݁͠Ռͷ CodeRefΛΩϟογϡ
͍ʂʂʂʂʂʂ
·ͱΊ evalศར
͋Γ͕ͱ͏͍͟͝·ͨ͠