forked from elixir-image/image
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathyuv_para.exs
55 lines (52 loc) · 1.27 KB
/
yuv_para.exs
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
raw_yuv_file = Path.expand("./test/support/images/image.yuv")
{:ok, yuv} = File.read(raw_yuv_file)
fun = fn ->
{:ok, rgb} = Image.YUV.new_from_binary(yuv, 1920, 1080, :C420)
{:ok, _yuv} = Image.YUV.write_to_binary(rgb, :C420)
end
Benchee.run(%{
convert: fn ->
{:ok, rgb} = Image.YUV.new_from_binary(yuv, 1920, 1080, :C420)
{:ok, _yuv} = Image.YUV.write_to_binary(rgb, :C420)
end,
convert_20: fn ->
[
Task.async(fun),
Task.async(fun),
Task.async(fun),
Task.async(fun),
Task.async(fun),
Task.async(fun),
Task.async(fun),
Task.async(fun),
Task.async(fun),
Task.async(fun),
Task.async(fun),
Task.async(fun),
Task.async(fun),
Task.async(fun),
Task.async(fun),
Task.async(fun),
Task.async(fun),
Task.async(fun),
Task.async(fun),
Task.async(fun)
]
|> Task.await_many()
end,
convert_10: fn ->
[
Task.async(fun),
Task.async(fun),
Task.async(fun),
Task.async(fun),
Task.async(fun),
Task.async(fun),
Task.async(fun),
Task.async(fun),
Task.async(fun),
Task.async(fun)
]
|> Task.await_many()
end
})