Filename | /home/mickey/git_tree/PONAPI/Server/lib/Test/PONAPI/Repository/MockDB/Loader.pm |
Statements | Executed 19 statements in 1.18ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 482µs | 666ms | load | Test::PONAPI::Repository::MockDB::Loader::
1 | 1 | 1 | 22µs | 1.18ms | _build_dbh | Test::PONAPI::Repository::MockDB::Loader::
1 | 1 | 1 | 20µs | 3.33ms | BEGIN@4 | Test::PONAPI::Repository::MockDB::Loader::
1 | 1 | 1 | 11µs | 30µs | BEGIN@6 | Test::PONAPI::Repository::MockDB::Loader::
1 | 1 | 1 | 11µs | 343µs | _build_dbd | Test::PONAPI::Repository::MockDB::Loader::
1 | 1 | 1 | 10µs | 34µs | BEGIN@14 | Test::PONAPI::Repository::MockDB::Loader::
1 | 1 | 1 | 8µs | 86µs | BEGIN@98 | Test::PONAPI::Repository::MockDB::Loader::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | # ABSTRACT: mock repository loader | ||||
2 | package Test::PONAPI::Repository::MockDB::Loader; | ||||
3 | |||||
4 | 2 | 54µs | 2 | 6.63ms | # spent 3.33ms (20µs+3.31) within Test::PONAPI::Repository::MockDB::Loader::BEGIN@4 which was called:
# once (20µs+3.31ms) by Test::PONAPI::Repository::MockDB::BEGIN@10 at line 4 # spent 3.33ms making 1 call to Test::PONAPI::Repository::MockDB::Loader::BEGIN@4
# spent 3.31ms making 1 call to Moose::import |
5 | |||||
6 | 2 | 46µs | 2 | 48µs | # spent 30µs (11+19) within Test::PONAPI::Repository::MockDB::Loader::BEGIN@6 which was called:
# once (11µs+19µs) by Test::PONAPI::Repository::MockDB::BEGIN@10 at line 6 # spent 30µs making 1 call to Test::PONAPI::Repository::MockDB::Loader::BEGIN@6
# spent 19µs making 1 call to Exporter::import |
7 | |||||
8 | 1 | 1µs | 1 | 6.57ms | has dbd => ( # spent 6.57ms making 1 call to Moose::has |
9 | is => 'ro', | ||||
10 | isa => 'Str', | ||||
11 | builder => '_build_dbd', | ||||
12 | ); | ||||
13 | |||||
14 | 2 | 246µs | 2 | 57µs | # spent 34µs (10+23) within Test::PONAPI::Repository::MockDB::Loader::BEGIN@14 which was called:
# once (10µs+23µs) by Test::PONAPI::Repository::MockDB::BEGIN@10 at line 14 # spent 34µs making 1 call to Test::PONAPI::Repository::MockDB::Loader::BEGIN@14
# spent 24µs making 1 call to Exporter::import |
15 | # spent 343µs (11+332) within Test::PONAPI::Repository::MockDB::Loader::_build_dbd which was called:
# once (11µs+332µs) by Test::PONAPI::Repository::MockDB::Loader::new at line 45 of (eval 45)[Eval/Closure.pm:144] | ||||
16 | 1 | 3µs | 1 | 323µs | my ($fh, $path) = tempfile("MockDB.db.XXXXXXX", TMPDIR => 1, UNLINK => 1); # spent 323µs making 1 call to File::Temp::tempfile |
17 | 1 | 14µs | 1 | 10µs | close $fh; # spent 10µs making 1 call to Test::PONAPI::Repository::MockDB::Loader::CORE:close |
18 | 1 | 4µs | return "DBI:SQLite:dbname=$path"; | ||
19 | } | ||||
20 | |||||
21 | 1 | 2µs | 1 | 2.35ms | has dbh => ( # spent 2.35ms making 1 call to Moose::has |
22 | is => 'ro', | ||||
23 | isa => 'DBI::db', | ||||
24 | lazy => 1, | ||||
25 | builder => '_build_dbh', | ||||
26 | ); | ||||
27 | |||||
28 | # spent 1.18ms (22µs+1.15) within Test::PONAPI::Repository::MockDB::Loader::_build_dbh which was called:
# once (22µs+1.15ms) by Test::PONAPI::Repository::MockDB::Loader::dbh at line 12 of (eval 45)[Eval/Closure.pm:144] | ||||
29 | 1 | 10µs | my $self = shift; | ||
30 | 1 | 10µs | 2 | 1.15ms | DBI->connect( $self->dbd, '', '', { RaiseError => 1 } ) # spent 1.15ms making 1 call to DBI::connect
# spent 3µs making 1 call to Test::PONAPI::Repository::MockDB::Loader::dbd |
31 | or die $DBI::errstr; | ||||
32 | } | ||||
33 | |||||
34 | # spent 666ms (482µs+665) within Test::PONAPI::Repository::MockDB::Loader::load which was called:
# once (482µs+665ms) by Test::PONAPI::Repository::MockDB::BUILD at line 43 of lib/Test/PONAPI/Repository/MockDB.pm | ||||
35 | 1 | 300ns | my $self = shift; | ||
36 | |||||
37 | 1 | 739µs | 69 | 1.33s | $self->dbh->do($_) for # spent 664ms making 23 calls to DBI::db::do, avg 28.9ms/call
# spent 663ms making 23 calls to DBD::SQLite::db::do, avg 28.8ms/call
# spent 1.50ms making 23 calls to Test::PONAPI::Repository::MockDB::Loader::dbh, avg 65µs/call |
38 | q< DROP TABLE IF EXISTS articles; >, | ||||
39 | q< CREATE TABLE IF NOT EXISTS articles ( | ||||
40 | id INTEGER PRIMARY KEY AUTOINCREMENT, | ||||
41 | title CHAR(64) NOT NULL, | ||||
42 | body TEXT NOT NULL, | ||||
43 | created DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||||
44 | updated DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||||
45 | status CHAR(10) NOT NULL DEFAULT "pending approval" ); >, | ||||
46 | |||||
47 | map(qq< INSERT INTO articles (title, body, created, updated, status) VALUES $_>, | ||||
48 | q<("JSON API paints my bikeshed!", "The shortest article. Ever.", | ||||
49 | "2015-05-22 14:56:29", "2015-05-22 14:56:29", "ok" )>, | ||||
50 | q<("A second title", "The 2nd shortest article. Ever.", | ||||
51 | "2015-06-22 14:56:29", "2015-06-22 14:56:29", "ok" )>, | ||||
52 | q<("a third one", "The 3rd shortest article. Ever.", | ||||
53 | "2015-07-22 14:56:29", "2015-07-22 14:56:29", "pending approval" ); >), | ||||
54 | |||||
55 | q< DROP TABLE IF EXISTS people; >, | ||||
56 | q< CREATE TABLE IF NOT EXISTS people ( | ||||
57 | id INTEGER PRIMARY KEY, | ||||
58 | name CHAR(64) NOT NULL DEFAULT "anonymous", | ||||
59 | age INTEGER NOT NULL DEFAULT "100", | ||||
60 | gender CHAR(10) NOT NULL DEFAULT "unknown" ); >, | ||||
61 | |||||
62 | map(qq< INSERT INTO people (id, name, age, gender) VALUES $_>, | ||||
63 | q<(42, "John", 80, "male")>, | ||||
64 | q<(88, "Jimmy", 18, "male")>, | ||||
65 | q<(91, "Diana", 30, "female")>), | ||||
66 | |||||
67 | q< DROP TABLE IF EXISTS rel_articles_people; >, | ||||
68 | q< CREATE TABLE IF NOT EXISTS rel_articles_people ( | ||||
69 | id_articles INTEGER NOT NULL PRIMARY KEY, | ||||
70 | id_people INTEGER NOT NULL | ||||
71 | ); >, | ||||
72 | |||||
73 | map(qq< INSERT INTO rel_articles_people (id_articles, id_people) VALUES $_>, | ||||
74 | q<(1, 42)>, | ||||
75 | q<(2, 88)>, | ||||
76 | q<(3, 91)>), | ||||
77 | |||||
78 | q< DROP TABLE IF EXISTS comments; >, | ||||
79 | q< CREATE TABLE IF NOT EXISTS comments ( | ||||
80 | id INTEGER PRIMARY KEY, | ||||
81 | body TEXT NOT NULL DEFAULT "" ); >, | ||||
82 | |||||
83 | map(qq< INSERT INTO comments (id, body) VALUES $_>, | ||||
84 | q<(5, "First!")>, | ||||
85 | q<(12, "I like XML better")>), | ||||
86 | |||||
87 | q< DROP TABLE IF EXISTS rel_articles_comments; >, | ||||
88 | q< CREATE TABLE IF NOT EXISTS rel_articles_comments ( | ||||
89 | id_articles INTEGER NOT NULL, | ||||
90 | id_comments INTEGER UNIQUE NOT NULL ); >, | ||||
91 | |||||
92 | map(qq< INSERT INTO rel_articles_comments (id_articles, id_comments) VALUES $_>, | ||||
93 | q<(2, 5)>, | ||||
94 | q<(2, 12)>); | ||||
95 | } | ||||
96 | |||||
97 | 1 | 3µs | 2 | 2.59ms | __PACKAGE__->meta->make_immutable; # spent 2.58ms making 1 call to Class::MOP::Class::make_immutable
# spent 12µs making 1 call to Test::PONAPI::Repository::MockDB::Loader::meta |
98 | 3 | 42µs | 2 | 164µs | # spent 86µs (8+78) within Test::PONAPI::Repository::MockDB::Loader::BEGIN@98 which was called:
# once (8µs+78µs) by Test::PONAPI::Repository::MockDB::BEGIN@10 at line 98 # spent 86µs making 1 call to Test::PONAPI::Repository::MockDB::Loader::BEGIN@98
# spent 78µs making 1 call to Moose::unimport |
99 | |||||
100 | __END__ |