Teng is an O/R mapper that provides methods like bulk_insert and fast_insert for efficiently inserting multiple rows into a database table. It also has features like lookup to retrieve a row by primary key, suppress_row_objects for improved performance by not creating row objects, and sql_comment to add comments to generated SQL for debugging. Teng aims to improve performance of database operations in Perl applications.
This document summarizes recent changes and features of the JSON and JSON::PP Perl modules. It discusses changes made to address issues, add experimental features like incremental parsing and UTF-16/32 support, and loosen validation of the PERL_JSON_BACKEND setting. It also provides examples of sorting hash keys during encoding and converting values during decoding. Remaining unimplemented features like validating Unicode characters and supporting newer JSON standards are acknowledged.
Perl 5.24 was released in 2016 with several notable changes including hashbang redirection to Perl 6, removal of autodereferencing, and performance enhancements. Perl 6 development progressed with the release of the Christmas roast specification tests and Rakudo becoming more stable on MoarVM while work continued on implementations for other platforms like JVM and JavaScript. The Perl community continued to enhance CPAN and develop new features for Perl 6 like TWEAK submethods and lexical module loading.
This document discusses recent changes and improvements made to the JSON and JSON::PP Perl modules, including fixing various issues, adding better and faster number detection, incremental parsing, and UTF-16/32 support in an experimental capacity. It also notes that specifying PERL_JSON_BACKEND=Cpanel::JSON::XS should now work properly and that a few incompatible changes may have been introduced between JSON::PP and Cpanel::JSON::XS.
This document provides tips ("kowaza" in Japanese) for monitoring various systems and processes using Mackerel. It discusses using check-procs and check-log plugins to monitor MySQL and log files. It also explores options for monitoring mount points and providing more informative messages for certain check results. The author is a senior engineer and Mackerel contributor.
The document discusses optimizing Perl code for prime number generation and Fibonacci number calculation. It explores different algorithms and data structures to improve performance, including memoization, struct of arrays, and avoiding unnecessary function calls in loops. Benchmark results show the optimizations significantly reduce execution times from hundreds of milliseconds to under 1 millisecond.
Teng is an O/R mapper that provides methods like bulk_insert and fast_insert for efficiently inserting multiple rows into a database table. It also has features like lookup to retrieve a row by primary key, suppress_row_objects for improved performance by not creating row objects, and sql_comment to add comments to generated SQL for debugging. Teng aims to improve performance of database operations in Perl applications.
This document summarizes recent changes and features of the JSON and JSON::PP Perl modules. It discusses changes made to address issues, add experimental features like incremental parsing and UTF-16/32 support, and loosen validation of the PERL_JSON_BACKEND setting. It also provides examples of sorting hash keys during encoding and converting values during decoding. Remaining unimplemented features like validating Unicode characters and supporting newer JSON standards are acknowledged.
Perl 5.24 was released in 2016 with several notable changes including hashbang redirection to Perl 6, removal of autodereferencing, and performance enhancements. Perl 6 development progressed with the release of the Christmas roast specification tests and Rakudo becoming more stable on MoarVM while work continued on implementations for other platforms like JVM and JavaScript. The Perl community continued to enhance CPAN and develop new features for Perl 6 like TWEAK submethods and lexical module loading.
This document discusses recent changes and improvements made to the JSON and JSON::PP Perl modules, including fixing various issues, adding better and faster number detection, incremental parsing, and UTF-16/32 support in an experimental capacity. It also notes that specifying PERL_JSON_BACKEND=Cpanel::JSON::XS should now work properly and that a few incompatible changes may have been introduced between JSON::PP and Cpanel::JSON::XS.
This document provides tips ("kowaza" in Japanese) for monitoring various systems and processes using Mackerel. It discusses using check-procs and check-log plugins to monitor MySQL and log files. It also explores options for monitoring mount points and providing more informative messages for certain check results. The author is a senior engineer and Mackerel contributor.
The document discusses optimizing Perl code for prime number generation and Fibonacci number calculation. It explores different algorithms and data structures to improve performance, including memoization, struct of arrays, and avoiding unnecessary function calls in loops. Benchmark results show the optimizations significantly reduce execution times from hundreds of milliseconds to under 1 millisecond.
- JSON has become the de facto standard format for data interchange, but it uses strict data types that Perl scalars do not directly map to
- Encoding Perl data into JSON can incorrectly change types if the scalar flags are modified
- The JSON::Types and Cpanel::JSON::XS::Type modules provide solutions by annotating Perl data with JSON types to avoid incorrect encoding
The document discusses the Crystal programming language. It notes that Crystal has had 12 minor version releases in the past year, with over 72 breaking changes, 200 new methods and macros added, and many bugs fixed. Some key updates discussed include the addition of 'crystal play' and 'crystal tool format' commands, removal of global variables, and updated syntax for class definitions. The conclusion encourages trying Crystal and joining the Crystal JP user group.
Aniki is a simple and fast ORM that focuses on object mapping, relationship support, and being pluggable/extendable. It aims to be simpler than alternatives like DBIx::Class by delegating tasks like transactions and SQL generation. Benchmark tests show Aniki performs SELECT, INSERT, and UPDATE operations faster than Teng and significantly faster than DBIx::Class, while also being easier to understand and extend.
Optimize perl5 code for perfomance freakskarupanerura
The document discusses optimizing Perl 5 code for performance. It focuses on optimizing regular expressions, variable access, and conditional branches. Specific techniques discussed include suppressing memory copying, optimizing regular expressions, instance caching, and using string evaluation, with warnings that string evaluation is dangerous. The document demonstrates benchmarks comparing different date/time parsing modules in Perl.
This document summarizes a Crystal library called router-simple that provides URI routing functionality. It begins with information about the author and their background. It then provides an example of using the router-simple library to define routes and match requests. Key features highlighted include Ruby-like syntax, type safety with optional restrictions, nil safety, support for generics, and use of PCRE for regular expressions. The document encourages listening to learn how to create your own Crystal libraries.
mRuby.pm allows embedding mruby, a lightweight Ruby implementation, into Perl 5. This allows business logic and configurations written in Ruby to be shared across an iOS, Android, and web application. By using mruby, the codebases can access common Ruby code, rather than having the logic duplicated in Swift, Java, and Perl. mRuby.pm uses XS to embed mruby, exposing both low-level and high-level APIs to call mruby code from Perl 5. This sharing of logic across platforms simplifies development and maintenance of a social game with logic for scoring, battles, and other processes.
This document discusses Perl 5 meta programming and provides examples of how to implement meta programming in Perl 5. It describes techniques like string eval, modifying the symbol table and typeglobs, using AUTOLOAD, Package::Stash, B:: modules, Class::Inspector, Class::Method::Modifiers, and Moo to get and set information about classes and define/modify methods and packages at runtime. It emphasizes writing tests and solving problems with existing modules when possible.
7. DBIをつかう
use DBI;
my $dbh = DBI->connect('dbi:SQLite:dbname=:memory:');
# .....
$dbh->disconnect;
13年3月23日土曜日
8. DBIをつかう
use DBI;
# SQLite(memory)
my $dbh = DBI->connect('dbi:SQLite:dbname=:memory:');
# SQLite(file)
my $dbh = DBI->connect('dbi:SQLite:dbname=local.sqlite');
# MySQL
my $dbh = DBI->connect(
'dbi:mysql:database=hoge;host=localhost',
'username',
'password',
);
13年3月23日土曜日
9. べんりメソッド
selectrow_*系
selectall_*系
selectcol_*系
do
prepare(_cached)?/execute
13年3月23日土曜日
10. よくつかうやつ
selectrow_array / selectrow_hashref
selectall_arrayref
selectcol_arrayref
do
13年3月23日土曜日
11. selectrow_array
# こんなかんじでかえってくる
# (1)
my ($id) = $dbh->selectrow_array(
'SELECT id FROM chibapm WHERE name = ?', undef, 'kaztr'
);
13年3月23日土曜日
12. selectrow_hashref
# こんなかんじでかえってくる
# { id => 1, name => 'kaztr' };
my $row = $dbh->selectrow_hashref(
'SELECT id, name FROM chibapm WHERE name = ?', undef, 'kaztr',
);
13年3月23日土曜日
13. selectall_arrayref
# こんなかんじでかえってくる
# [
# { id => 1, name => 'kaztr' },
# { id => 2, name => 'yoku0825' },
# { id => 3, name => 'hide_o_55' },
# ];
my $chibapm_list = $dbh->selectall_arrayref(
'SELECT id, name FROM chibapm WHERE name IN (?, ?, ?)',
+{ Slice => +{} },
'kaztr', 'yoku0825', 'hide_o_55'
);
13年3月23日土曜日
14. selectcol_arrayref(1)
# こんなかんじでかえってくる
# [ 1, 2, 3 ];
my $chibapm_id_list = $dbh->selectcol_arrayref(
'SELECT id FROM chibapm WHERE name IN (?, ?, ?)',
undef,
'kaztr', 'yoku0825', 'hide_o_55'
);
13年3月23日土曜日
15. selectcol_arrayref(2)
# こんなかんじでかえってくる
# [ 'kaztr', 1, 'yoku0825', 2, 'hide_o_55', 3 ];
my $chibapm_name2id_map = $dbh->selectcol_arrayref(
'SELECT name, id FROM chibapm WHERE name IN (?, ?, ?)',
+{ Columns => [1, 2] },
'kaztr', 'yoku0825', 'hide_o_55'
);
13年3月23日土曜日
16. selectcol_arrayref(3)
# こんなかんじでかえってくる
# (
# 'kaztr' => 1,
# 'yoku0825' => 2,
# 'hide_o_55' => 3,
# );
my %chibapm_name2id_map = @{ $dbh->selectcol_arrayref(
'SELECT name, id FROM chibapm WHERE name IN (?, ?, ?)',
+{ Columns => [1, 2] },
'kaztr', 'yoku0825', 'hide_o_55'
) };
say $chibapm_name2id_map{kaztr}; # 1
13年3月23日土曜日
17. do
# クエリ実行するだけー
# 変更された行数か、特になければ'0E0'を返す
$dbh->do(
'INSERT INTO chibapm (name) VALUES (?)',
undef,
'kenjiskywalker',
);
13年3月23日土曜日
26. select_one
# こんなかんじでかえってくる
# 1
my $id = $dbh->select_one(
'SELECT id FROM chibapm WHERE name = ?', 'kaztr'
);
# DBI#selectrow_array でもだいたいおなじことできる!
13年3月23日土曜日
27. select_row
# こんなかんじでかえってくる
# { id => 1, name => 'kaztr' };
my $row = $dbh->select_row(
'SELECT id, name FROM chibapm WHERE name = ?', 'kaztr',
);
# DBI#selectrow_hashref とおんなじ!
13年3月23日土曜日
28. select_all
# こんなかんじでかえってくる
# [
# { id => 1, name => 'kaztr' },
# { id => 2, name => 'yoku0825' },
# { id => 3, name => 'hide_o_55' },
# ];
my $chibapm_list = $dbh->select_all(
'SELECT id, name FROM chibapm WHERE name IN (?)',
['kaztr', 'yoku0825', 'hide_o_55']
);
# DBI#selectall_arrayref でもだいたいおんなじことできる
13年3月23日土曜日