forked from sisimai/rb-sisimai
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Benchmarks.mk
64 lines (56 loc) · 2.43 KB
/
Benchmarks.mk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# rb-sisimai/Benchmarks.mk
# ____ _ _ _
# | __ ) ___ _ __ ___| |__ _ __ ___ __ _ _ __| | _____ _ __ ___ | | __
# | _ \ / _ \ '_ \ / __| '_ \| '_ ` _ \ / _` | '__| |/ / __| | '_ ` _ \| |/ /
# | |_) | __/ | | | (__| | | | | | | | | (_| | | | <\__ \_| | | | | | <
# |____/ \___|_| |_|\___|_| |_|_| |_| |_|\__,_|_| |_|\_\___(_)_| |_| |_|_|\_\
# -----------------------------------------------------------------------------
SHELL := /bin/sh
HERE := $(shell pwd)
NAME := Sisimai
RUBY ?= ruby
MKDIR := mkdir -p
LS := ls -1
CP := cp
EMAILROOTDIR := set-of-emails
PUBLICEMAILS := $(EMAILROOTDIR)/maildir/bsd
DOSFORMATSET := $(EMAILROOTDIR)/maildir/dos
MACFORMATSET := $(EMAILROOTDIR)/maildir/mac
PRIVATEMAILS := $(EMAILROOTDIR)/private
SPEEDTESTDIR := tmp/emails-for-speed-test
COMMANDARGVS := -I./lib -rsisimai
TOBEEXECUTED := 'Sisimai.make($$*.shift, delivered: true)' $(PUBLICMAILS)
PROFILEARGVS := -rrblineprof -rrblineprof-report
PROFCOMMANDS := 'p = lineprof(%r|./lib/sisimai|) { Sisimai.make($$*.shift, delivered: true) }; LineProf.report(p, out: "pf")'
HOWMANYMAILS := $(RUBY) $(COMMANDARGVS) -le 'puts Sisimai.make($$*.shift, delivered: true).size'
# -----------------------------------------------------------------------------
.PHONY: clean
emails-for-speed-test:
@ rm -fr ./$(SPEEDTESTDIR)
@ $(MKDIR) $(SPEEDTESTDIR)
@ $(CP) -Rp $(PUBLICEMAILS)/*.eml $(SPEEDTESTDIR)/
@ test -d $(PRIVATEMAILS) && find $(PRIVATEMAILS) -type f -name '*.eml' -exec $(CP) -Rp {} $(SPEEDTESTDIR)/ \; || true
speed-test: emails-for-speed-test
@ echo `$(HOWMANYMAILS) $(SPEEDTESTDIR)` emails in $(SPEEDTESTDIR)
@ echo -------------------------------------------------------------------
@ uptime
@ echo -------------------------------------------------------------------
@ n=1; while [ "$$n" -le "10" ]; do \
time $(RUBY) $(COMMANDARGVS) -e $(TOBEEXECUTED) $(SPEEDTESTDIR) > /dev/null; \
sleep 2; \
n=`expr $$n + 1`; \
done
profile:
@ uptime
$(RUBY) $(COMMANDARGVS) $(PROFILEARGVS) -e $(PROFCOMMANDS) $(SPEEDTESTDIR)
cat ./pf > profile-`date '+%Y-%m-%d-%T'`.txt
$(RM) ./pf
loc:
@ for v in `find lib -type f -name '*.rb'`; do \
x=`wc -l $$v | awk '{ print $$1 }'`; \
z=`grep -E '^\s*#|^$$' $$v | wc -l | awk '{ print $$1 }'`; \
echo "$$x - $$z" | bc ;\
done | awk '{ s += $$1 } END { print s }'
clean:
find . -type f -name 'profiling-*' -ctime +1 -delete
rm -r $(SPEEDTESTDIR)