Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- setup() {
- iter=1000
- file=$(mktemp ~/XXX.db)
- sqlite3 "$file" 'CREATE TABLE numbers(base INTEGER, square INTEGER, cube INTEGER);'
- }
- multi() {
- for i in $(seq $iter); do
- sqlite3 "$file" "INSERT INTO numbers(base, square, cube) VALUES($i, $((i*i)), $((i*i*i)));"
- done
- }
- single() {
- for i in $(seq $iter); do
- echo "INSERT INTO numbers(base, square, cube) VALUES($i, $((i*i)), $((i*i*i)));"
- done |sqlite3 "$file"
- }
- tx() {
- {
- echo 'BEGIN;'
- for i in $(seq $iter); do
- echo "INSERT INTO numbers(base, square, cube) VALUES($i, $((i*i)), $((i*i*i)));"
- done
- echo 'COMMIT;'
- } |sqlite3 "$file"
- }
- case "$1" in
- multi|single|tx)
- setup
- "$1"
- rm -f "$file"
- ;;
- *)
- exec echo "usage: ${0##*/} [multi|single|tx]"
- ;;
- esac
- exit 0
- $ time ./sqlitest multi
- real 0m20,280s
- user 0m3,695s
- sys 0m1,342s
- $ time ./sqlitest single
- real 0m16,208s
- user 0m0,102s
- sys 0m0,521s
- $ time ./sqlitest tx
- real 0m0,059s
- user 0m0,016s
- sys 0m0,008s
- $ strace -fc -e '!wait4' ~/sqlitest multi
- % time seconds usecs/call calls errors syscall
- ------ ----------- ----------- --------- --------- ----------------
- 12,98 0,138697 2 47078 mmap
- 10,92 0,116754 5 21035 3003 openat
- 8,67 0,092688 9 10009 pwrite64
- 8,19 0,087539 29 3003 fdatasync
- 7,15 0,076395 4 17019 fcntl
- 6,51 0,069634 3 22054 close
- 5,88 0,062860 2 26079 read
- 5,41 0,057829 2 22037 1001 fstat
- 4,70 0,050257 3 13029 mprotect
- 4,00 0,042768 4 9030 4020 stat
- 3,60 0,038507 38 1001 unlink
- 3,25 0,034777 11 3003 socket
- 2,41 0,025719 8 3007 munmap
- 2,22 0,023742 4 5737 pread64
- 2,11 0,022570 1 13028 3 lseek
- 2,09 0,022301 7 3003 3003 connect
- 1,71 0,018269 3 6008 getpid
- 1,50 0,016062 15 1004 rt_sigreturn
- 1,49 0,015897 2 6022 brk
- 1,12 0,011992 11 1004 clone
- 0,66 0,007067 2 3010 rt_sigaction
- 0,58 0,006184 3 2003 1001 ioctl
- 0,52 0,005550 2 2006 1005 access
- 0,33 0,003524 3 1001 lstat
- 0,33 0,003512 3 1002 geteuid
- 0,27 0,002937 2 1001 getcwd
- 0,26 0,002819 2 1002 getuid
- 0,22 0,002375 1 2010 1005 arch_prctl
- 0,22 0,002367 2 1001 prlimit64
- 0,21 0,002209 2 1001 rt_sigprocmask
- 0,20 0,002149 2 1001 set_tid_address
- 0,20 0,002098 2 1001 set_robust_list
- 0,07 0,000783 0 1005 execve
- 0,00 0,000042 21 2 pipe
- 0,00 0,000000 0 2 write
- 0,00 0,000000 0 2 dup2
- 0,00 0,000000 0 1 getgid
- 0,00 0,000000 0 2 getppid
- 0,00 0,000000 0 1 newfstatat
- 0,00 0,000000 0 1 unlinkat
- ------ ----------- ----------- --------- --------- ----------------
- 100.00 1,068873 251245 14041 total
- $ strace -fc -e '!wait4' ~/sqlitest single
- % time seconds usecs/call calls errors syscall
- ------ ----------- ----------- --------- --------- ----------------
- 25,97 0,184226 18 10009 pwrite64
- 22,30 0,158217 52 3003 fdatasync
- 13,27 0,094113 10 9027 fcntl
- 10,99 0,077991 73 1055 6 openat
- 10,20 0,072388 72 1001 unlink
- 5,64 0,040014 9 4035 2022 stat
- 3,79 0,026888 24 1081 1 close
- 3,22 0,022830 11 2006 pread64
- 2,35 0,016657 8 2058 2 fstat
- 1,03 0,007335 7 1013 getpid
- 1,02 0,007205 7 1002 geteuid
- 0,06 0,000446 3 125 mmap
- 0,06 0,000433 3 124 read
- 0,03 0,000191 4 42 mprotect
- 0,01 0,000100 16 6 socket
- 0,01 0,000094 2 41 3 lseek
- 0,01 0,000080 8 10 munmap
- 0,01 0,000067 11 6 6 connect
- 0,01 0,000051 1 28 brk
- 0,00 0,000026 2 13 rt_sigaction
- 0,00 0,000022 4 5 3 ioctl
- 0,00 0,000016 2 8 6 access
- 0,00 0,000011 5 2 lstat
- 0,00 0,000009 4 2 getcwd
- 0,00 0,000009 0 12 6 arch_prctl
- 0,00 0,000009 4 2 set_tid_address
- 0,00 0,000009 4 2 prlimit64
- 0,00 0,000008 4 2 rt_sigprocmask
- 0,00 0,000008 2 3 getuid
- 0,00 0,000008 4 2 set_robust_list
- 0,00 0,000000 0 1002 write
- 0,00 0,000000 0 6 rt_sigreturn
- 0,00 0,000000 0 3 pipe
- 0,00 0,000000 0 4 dup2
- 0,00 0,000000 0 6 clone
- 0,00 0,000000 0 6 execve
- 0,00 0,000000 0 1 getgid
- 0,00 0,000000 0 2 getppid
- 0,00 0,000000 0 1 newfstatat
- 0,00 0,000000 0 1 unlinkat
- ------ ----------- ----------- --------- --------- ----------------
- 100.00 0,709461 36757 2055 total
- $ strace -fc -e '!wait4' ~/sqlitest tx
- % time seconds usecs/call calls errors syscall
- ------ ----------- ----------- --------- --------- ----------------
- 43,62 0,003797 4 903 read
- 32,36 0,002817 2 1004 write
- 3,92 0,000341 2 125 mmap
- 3,41 0,000297 7 42 mprotect
- 3,24 0,000282 5 56 6 openat
- 1,55 0,000135 1 82 1 close
- 1,53 0,000133 2 60 2 fstat
- 1,26 0,000110 3 36 fcntl
- 1,16 0,000101 16 6 socket
- 1,05 0,000091 4 19 pwrite64
- 0,85 0,000074 1 39 24 stat
- 0,85 0,000074 7 10 munmap
- 0,70 0,000061 1 41 3 lseek
- 0,70 0,000061 10 6 6 connect
- 0,67 0,000058 29 2 lstat
- 0,63 0,000055 6 8 pread64
- 0,53 0,000046 7 6 fdatasync
- 0,46 0,000040 2 14 getpid
- 0,24 0,000021 1 13 rt_sigaction
- 0,23 0,000020 0 28 brk
- 0,22 0,000019 3 5 3 ioctl
- 0,14 0,000012 6 2 unlink
- 0,10 0,000009 0 12 6 arch_prctl
- 0,10 0,000009 4 2 set_robust_list
- 0,09 0,000008 4 2 rt_sigprocmask
- 0,09 0,000008 4 2 getcwd
- 0,08 0,000007 3 2 prlimit64
- 0,07 0,000006 2 3 getuid
- 0,07 0,000006 2 3 geteuid
- 0,07 0,000006 3 2 set_tid_address
- 0,00 0,000000 0 6 rt_sigreturn
- 0,00 0,000000 0 8 6 access
- 0,00 0,000000 0 3 pipe
- 0,00 0,000000 0 4 dup2
- 0,00 0,000000 0 6 clone
- 0,00 0,000000 0 6 execve
- 0,00 0,000000 0 1 getgid
- 0,00 0,000000 0 2 getppid
- 0,00 0,000000 0 1 newfstatat
- 0,00 0,000000 0 1 unlinkat
- ------ ----------- ----------- --------- --------- ----------------
- 100.00 0,008704 2573 57 total
- $ perf stat ~/sqlitest multi
- Performance counter stats for '/home/matteo/sqlitest multi':
- 4.988,83 msec task-clock:u # 0,239 CPUs utilized
- 0 context-switches:u # 0,000 K/sec
- 0 cpu-migrations:u # 0,000 K/sec
- 236.329 page-faults:u # 0,047 M/sec
- 1.681.863.847 cycles:u # 0,337 GHz
- 2.227.529.857 instructions:u # 1,32 insn per cycle
- 424.428.941 branches:u # 85,076 M/sec
- 20.166.807 branch-misses:u # 4,75% of all branches
- 20,832574432 seconds time elapsed
- 3,668548000 seconds user
- 1,561489000 seconds sys
- $ perf stat ~/sqlitest single
- Performance counter stats for '/home/matteo/sqlitest single':
- 596,11 msec task-clock:u # 0,037 CPUs utilized
- 0 context-switches:u # 0,000 K/sec
- 0 cpu-migrations:u # 0,000 K/sec
- 819 page-faults:u # 0,001 M/sec
- 83.695.687 cycles:u # 0,140 GHz
- 39.930.046 instructions:u # 0,48 insn per cycle
- 8.706.299 branches:u # 14,605 M/sec
- 1.183.653 branch-misses:u # 13,60% of all branches
- 16,330267488 seconds time elapsed
- 0,101328000 seconds user
- 0,605390000 seconds sys
- $ perf stat ~/sqlitest tx
- Performance counter stats for '/home/matteo/sqlitest tx':
- 20,00 msec task-clock:u # 0,368 CPUs utilized
- 0 context-switches:u # 0,000 K/sec
- 0 cpu-migrations:u # 0,000 K/sec
- 826 page-faults:u # 0,041 M/sec
- 15.823.939 cycles:u # 0,791 GHz
- 33.241.555 instructions:u # 2,10 insn per cycle
- 7.149.309 branches:u # 357,389 M/sec
- 74.997 branch-misses:u # 1,05% of all branches
- 0,054352832 seconds time elapsed
- 0,020880000 seconds user
- 0,000000000 seconds sys
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement