-
Notifications
You must be signed in to change notification settings - Fork 4
/
benchmark.py
61 lines (43 loc) · 1.57 KB
/
benchmark.py
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
import timeit
import sipskia
from wand.image import Image
f = open('sample_like.jpg')
s = f.read()
f.close()
ws = sipskia.convert_webp(s, len(s), True)
def crop_image(image_data, size_crop):
from_width, from_height = (image_data.width, image_data.height)
to_width, to_height = size_crop
left = int((from_width - to_width) / 2)
top = int((from_height - to_height) / 2)
right = left + to_width
bottom = top + to_height
image_data.crop(left, top, right, bottom)
return image_data
def test_wand():
image_data = Image(blob=s)
image_data.compression_quality = 70
is_gallery_card = False
image_data_size = (image_data.width, image_data.height)
image_size = (720, 720)
if is_gallery_card:
image_size = (720, 1120)
if image_size != image_data_size:
result = image_data.resize(image_size[0], image_size[1])
with image_data.clone() as img:
result = img = crop_image(img, (720, 472))
# 공감전용 카드의 경우 댓글용 이미지를 생성하지 않는다.
if not is_gallery_card:
result = img.resize(460, 310)
result = image_data.resize(360, 360)
result = image_data.resize(132, 132)
return result
def test_skia():
result = sipskia.convert_original(ws, len(ws))
result = sipskia.convert_list(ws, len(ws))
result = sipskia.convert_reply(ws, len(ws))
result = sipskia.convert_medium(ws, len(ws))
result = sipskia.convert_thumbnail(ws, len(ws))
return result
print(timeit.timeit(test_wand, number=10))
print(timeit.timeit(test_skia, number=10))