Skip to content

Commit 219dc6a

Browse files
committed
Use BenchmarkTools to test allocations
1 parent 2721213 commit 219dc6a

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

Project.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "ChunkedCSV"
22
uuid = "c0d0730e-6432-44b2-a51e-6ec55e1c8b99"
3-
authors = ["Tomáš Drvoštěp <tomas.drvostep@gmail.com>"]
43
version = "0.1.2"
4+
authors = ["Tomáš Drvoštěp <tomas.drvostep@gmail.com>"]
55

66
[deps]
77
ChunkedBase = "a380dd43-0ebf-4429-88d6-6f06ea920732"
@@ -13,6 +13,7 @@ SnoopPrecompile = "66db9d55-30c0-4569-8b51-7e840670fc0c"
1313
TimeZones = "f269a46b-ccf7-5d73-abea-4c690281aa53"
1414

1515
[compat]
16+
BenchmarkTools = "1.6"
1617
ChunkedBase = "0.3"
1718
Dates = "1"
1819
FixedPointDecimals = "0.4.3, 0.5"
@@ -24,11 +25,12 @@ julia = "1.10"
2425

2526
[extras]
2627
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
28+
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
2729
CodecZlibNG = "642d12eb-acb5-4437-bcfc-a25e07ad685c"
2830
JET = "c3a54625-cd67-489e-a8e7-0a5a0ff4e31b"
2931
Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
3032
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
3133
UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
3234

3335
[targets]
34-
test = ["Aqua", "CodecZlibNG", "JET", "Logging", "Test", "UUIDs"]
36+
test = ["Aqua", "BenchmarkTools", "CodecZlibNG", "JET", "Logging", "Test", "UUIDs"]

test/guess_datetime.jl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@ using Dates
22
using ChunkedCSV
33
using Parsers
44
using Test
5+
using BenchmarkTools
56

67
const DT = b"1969-07-20 20:17:00"
78

8-
macro test_noalloc(e) :(@test(@allocated($(esc(e))) == 0)) end
9-
109
@testset "GuessDateTime" begin
1110
@testset "Parsing UTC equivalent timezones does not allocate" begin
1211
for tz in (b"-00", b"+00", b"-0000", b"+0000", b"-00:00", b"+00:00", b"UTC", b"GMT")
@@ -15,7 +14,7 @@ macro test_noalloc(e) :(@test(@allocated($(esc(e))) == 0)) end
1514
res = Parsers.xparse(ChunkedCSV.GuessDateTime, dt, 1, length(dt), Parsers.OPTIONS, DateTime)
1615
@test res.val == DateTime(1969, 7, 20, 20, 17)
1716
@test Parsers.ok(res.code)
18-
@test_noalloc Parsers.xparse(ChunkedCSV.GuessDateTime, dt, 1, length(dt), Parsers.OPTIONS, DateTime)
17+
@ballocated Parsers.xparse(ChunkedCSV.GuessDateTime, $dt, 1, length($dt), Parsers.OPTIONS, DateTime) == 0
1918
end
2019
end
2120
end

0 commit comments

Comments
 (0)