Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
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
88
Perl Meets \w+ あるいは開発を支えるPerl活用の実例集
karupanerura
0
76
log
karupanerura
1
110
Use Perl as Better Shell Script
karupanerura
0
910
GoでParserを書く
karupanerura
4
1.1k
マイ隙間家具OSSたちのご紹介
karupanerura
2
300
Mustache Template 話 2024
karupanerura
0
67
1つの言語を原点に色々な言語を学ぶということ
karupanerura
4
3.6k
Javaの実装をPerlでテストする
karupanerura
0
1.4k
Other Decks in Technology
See All in Technology
白金鉱業Meetup_Vol.24_「AIエージェントは分けるほど良い」は本当か? / Is it true that “the more you divide AI agents, the better”?
brainpadpr
1
360
Bedrock AgentCore RuntimeでAuth0 Changelog調査AIをアップグレードした話
t5u8a5a
1
120
SONiC Scale-Up Working Group から探る Scale-UpやUltraEthernet機能の実装方法
ebiken
PRO
2
280
AI駆動開発を通して感じた、 AI時代のデザイナーの役割変化
whisaiyo
3
2k
Oracle AI Database@Google Cloud:サービス概要のご紹介
oracle4engineer
PRO
6
1.5k
Bucharest Tech Week 2026 - Reinventing testing practices in the AI era
edeandrea
PRO
1
150
自律型AIエージェントは何を破壊するのか
kojira
0
160
失敗を経て、Harness Engineering で 大切にしたいことを考える / Learning from Failure: What Matters in Harness Engineering
bitkey
PRO
1
360
20260619 私の日常業務での生成 AI 活用
masaruogura
1
200
Agent Skills設計で柔軟性と硬さのバランスが難しい話
nassy20
0
130
脆弱性対応、どこで線を引くか
rymiyamoto
1
380
Oracle AI Database@AWS:サービス概要のご紹介
oracle4engineer
PRO
4
2.9k
Featured
See All Featured
How to Talk to Developers About Accessibility
jct
2
230
Building a Modern Day E-commerce SEO Strategy
aleyda
45
9.1k
Game over? The fight for quality and originality in the time of robots
wayneb77
1
200
How to Align SEO within the Product Triangle To Get Buy-In & Support - #RIMC
aleyda
2
1.5k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
2.9k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
254
22k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.5k
Building a Scalable Design System with Sketch
lauravandoore
463
34k
The Straight Up "How To Draw Better" Workshop
denniskardys
239
140k
Rails Girls Zürich Keynote
gr2m
96
14k
Designing Powerful Visuals for Engaging Learning
tmiket
1
410
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ศར
͋Γ͕ͱ͏͍͟͝·ͨ͠