Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add a TOML standard library to Julia #37034

Merged
merged 2 commits into from
Aug 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions base/sysimg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ let
:SuiteSparse,
:Distributed,
:SharedArrays,
:TOML,
:Pkg,
:Test,
:REPL,
Expand Down
2 changes: 1 addition & 1 deletion stdlib/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ $(build_datarootdir)/julia/stdlib/$(VERSDIR):
STDLIBS = Base64 CRC32c Dates DelimitedFiles Distributed FileWatching \
Future InteractiveUtils Libdl LibGit2 LinearAlgebra Logging \
Markdown Mmap Printf Profile Random REPL Serialization SHA \
SharedArrays Sockets SparseArrays SuiteSparse Test Unicode UUIDs
SharedArrays Sockets SparseArrays SuiteSparse Test TOML Unicode UUIDs
STDLIBS_EXT = Pkg Statistics
PKG_GIT_URL := git://github.com/JuliaLang/Pkg.jl.git
PKG_TAR_URL = https://api.github.com/repos/JuliaLang/Pkg.jl/tarball/$1
Expand Down
5 changes: 5 additions & 0 deletions stdlib/TOML/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*.jl.cov
*.jl.*.cov
*.jl.mem
docs/build
Manifest.toml
22 changes: 22 additions & 0 deletions stdlib/TOML/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
MIT License

Copyright (c) 2016-2020 Art Wild, Julia Computing, Inc., Kristoffer Carlsson and
contributors.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
12 changes: 12 additions & 0 deletions stdlib/TOML/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name = "TOML"
uuid = "fa267f1f-6049-4f14-aa54-33bafae1ed76"
version = "0.1.0"

[deps]
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Test"]
141 changes: 141 additions & 0 deletions stdlib/TOML/benchmark/Manifest.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
# This file is machine-generated - editing it directly is not advised

[[AbstractTrees]]
deps = ["Markdown"]
git-tree-sha1 = "33e450545eaf7699da1a6e755f9ea65f14077a45"
uuid = "1520ce14-60c1-5f80-bbc7-55ef81b5835c"
version = "0.3.3"

[[Base64]]
uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"

[[BenchmarkTools]]
deps = ["JSON", "Logging", "Printf", "Statistics", "UUIDs"]
git-tree-sha1 = "9e62e66db34540a0c919d72172cc2f642ac71260"
uuid = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
version = "0.5.0"

[[Dates]]
deps = ["Printf"]
uuid = "ade2ca70-3891-5945-98fb-dc099432e06a"

[[Distributed]]
deps = ["Random", "Serialization", "Sockets"]
uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b"

[[InteractiveUtils]]
deps = ["Markdown"]
uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240"

[[JSON]]
deps = ["Dates", "Mmap", "Parsers", "Unicode"]
git-tree-sha1 = "b34d7cef7b337321e97d22242c3c2b91f476748e"
uuid = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
version = "0.21.0"

[[LeftChildRightSiblingTrees]]
deps = ["AbstractTrees"]
git-tree-sha1 = "71be1eb5ad19cb4f61fa8c73395c0338fd092ae0"
uuid = "1d6d02ad-be62-4b6b-8a6d-2f90e265016e"
version = "0.1.2"

[[LibGit2]]
deps = ["Printf"]
uuid = "76f85450-5226-5b5a-8eaa-529ad045b433"

[[Libdl]]
uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb"

[[LinearAlgebra]]
deps = ["Libdl"]
uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"

[[Logging]]
uuid = "56ddb016-857b-54e1-b83d-db4d58db5568"

[[Markdown]]
deps = ["Base64"]
uuid = "d6f4376e-aef5-505a-96c1-9c027394607a"

[[Mmap]]
uuid = "a63ad114-7e13-5084-954f-fe012c677804"

[[Parsers]]
deps = ["Dates", "Test"]
git-tree-sha1 = "8077624b3c450b15c087944363606a6ba12f925e"
uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0"
version = "1.0.10"

[[Pkg]]
deps = ["Dates", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "UUIDs"]
uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"

[[PkgBenchmark]]
deps = ["BenchmarkTools", "Dates", "InteractiveUtils", "JSON", "LibGit2", "Logging", "Pkg", "Printf", "TerminalLoggers", "UUIDs"]
git-tree-sha1 = "6e2856f677f8dcab289ded9c3ffb018fad38f29c"
uuid = "32113eaa-f34f-5b0d-bd6c-c81e245fc73d"
version = "0.2.10"

[[Printf]]
deps = ["Unicode"]
uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7"

[[ProgressLogging]]
deps = ["Logging", "SHA", "UUIDs"]
git-tree-sha1 = "59398022b661b6fd569f25de6b18fde39843196a"
uuid = "33c8b6b6-d38a-422a-b730-caa89a2f386c"
version = "0.1.3"

[[REPL]]
deps = ["InteractiveUtils", "Markdown", "Sockets"]
uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"

[[Random]]
deps = ["Serialization"]
uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"

[[SHA]]
uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce"

[[Serialization]]
uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b"

[[Sockets]]
uuid = "6462fe0b-24de-5631-8697-dd941f90decc"

[[SparseArrays]]
deps = ["LinearAlgebra", "Random"]
uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"

[[StableRNGs]]
deps = ["Random", "Test"]
git-tree-sha1 = "705f8782b1d532c6db75e0a986fb848a629f971a"
uuid = "860ef19b-820b-49d6-a774-d7a799459cd3"
version = "0.1.1"

[[Statistics]]
deps = ["LinearAlgebra", "SparseArrays"]
uuid = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"

[[TOML]]
deps = ["Dates"]
path = ".."
uuid = "fa267f1f-6049-4f14-aa54-33bafae1ed76"
version = "0.1.0"

[[TerminalLoggers]]
deps = ["LeftChildRightSiblingTrees", "Logging", "Markdown", "Printf", "ProgressLogging", "UUIDs"]
git-tree-sha1 = "cbea752b5eef52a3e1188fb31580c3e4fa0cbc35"
uuid = "5d786b92-1e48-4d6f-9151-6b4477ca9bed"
version = "0.1.2"

[[Test]]
deps = ["Distributed", "InteractiveUtils", "Logging", "Random"]
uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[[UUIDs]]
deps = ["Random", "SHA"]
uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"

[[Unicode]]
uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5"
6 changes: 6 additions & 0 deletions stdlib/TOML/benchmark/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[deps]
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
PkgBenchmark = "32113eaa-f34f-5b0d-bd6c-c81e245fc73d"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3"
TOML = "fa267f1f-6049-4f14-aa54-33bafae1ed76"
79 changes: 79 additions & 0 deletions stdlib/TOML/benchmark/benchmarks.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
using BenchmarkTools
import TOML
import Random
import StableRNGs

randstring(args...) = Random.randstring(StableRNGs.StableRNG(0), args...)
rand(args...) = Random.rand(StableRNGs.StableRNG(0), args...)

const SUITE = BenchmarkGroup()


##########
# Arrays #
##########

SUITE["arrays"] = BenchmarkGroup()

const homogeneous_array = "foo = [" * join(ones(Int, 10^5), ',') * "]"
SUITE["arrays"]["homogeneous"] = @benchmarkable TOML.parse(homogeneous_array)

const heterogeneous_array = "foo = [1.0," * join(ones(Int, 10^5), ',') * "]"
SUITE["arrays"]["heterogeneous"] = @benchmarkable TOML.parse(heterogeneous_array)


###########
# Strings #
###########

SUITE["strings"] = BenchmarkGroup()

const long_string = "foo = " * repr(randstring(10^6))
SUITE["strings"]["long"] = @benchmarkable TOML.parse(long_string)

const short_strings = "foo = [" * join([repr(randstring(3)) for i in 1:10^4], ',') * "]"
SUITE["strings"]["short"] = @benchmarkable TOML.parse(short_strings)


###########
# Numbers #
###########

SUITE["numbers"] = BenchmarkGroup()

const integer_array = "foo = [" * join(rand(Int, 10^5), ',') * "]"
SUITE["numbers"]["integers"] = @benchmarkable TOML.parse(integer_array)

const float_array = "foo = [" * join(rand(10^5), ',') * "]"
SUITE["numbers"]["floats"] = @benchmarkable TOML.parse(float_array)


###################
# Array of Tables #
###################

SUITE["array of tables"] = BenchmarkGroup()

const many_empty_array_of_tables =
repeat("[[foo]] \n", 10^4)
SUITE["array of tables"]["empty"] = @benchmarkable TOML.parse(many_empty_array_of_tables)


#################
# Registry file #
#################

SUITE["registry"] = BenchmarkGroup()

const registry_toml = read(joinpath(@__DIR__, "files", "Registry.toml"), String)
SUITE["registry"]["Registry.toml"] = @benchmarkable TOML.parse(registry_toml)

const compat_toml = read(joinpath(@__DIR__, "files", "Compat.toml"), String)
SUITE["registry"]["Compat.toml"] = @benchmarkable TOML.parse(compat_toml)


############
# Overhead #
############

SUITE["parse empty"] = @benchmarkable TOML.parse("")
Loading