From d7824df50c6aac8bf17809f0e1e20162ec520e98 Mon Sep 17 00:00:00 2001 From: Timofey Solomko Date: Mon, 13 Sep 2021 17:32:16 +0300 Subject: [PATCH] [swcomp] Move most bench commands into BenchmarkGroup file --- .../swcomp/Benchmarks/BenchmarkGroup.swift | 97 +++++++++++++++++++ Sources/swcomp/Benchmarks/CompBz2.swift | 20 ---- Sources/swcomp/Benchmarks/CompDeflate.swift | 20 ---- Sources/swcomp/Benchmarks/Info7z.swift | 20 ---- Sources/swcomp/Benchmarks/InfoTar.swift | 20 ---- Sources/swcomp/Benchmarks/InfoZip.swift | 20 ---- Sources/swcomp/Benchmarks/UnBz2.swift | 20 ---- Sources/swcomp/Benchmarks/UnGzip.swift | 20 ---- Sources/swcomp/Benchmarks/UnXz.swift | 20 ---- 9 files changed, 97 insertions(+), 160 deletions(-) delete mode 100644 Sources/swcomp/Benchmarks/CompBz2.swift delete mode 100644 Sources/swcomp/Benchmarks/CompDeflate.swift delete mode 100644 Sources/swcomp/Benchmarks/Info7z.swift delete mode 100644 Sources/swcomp/Benchmarks/InfoTar.swift delete mode 100644 Sources/swcomp/Benchmarks/InfoZip.swift delete mode 100644 Sources/swcomp/Benchmarks/UnBz2.swift delete mode 100644 Sources/swcomp/Benchmarks/UnGzip.swift delete mode 100644 Sources/swcomp/Benchmarks/UnXz.swift diff --git a/Sources/swcomp/Benchmarks/BenchmarkGroup.swift b/Sources/swcomp/Benchmarks/BenchmarkGroup.swift index 8c74afb6..61516c3b 100644 --- a/Sources/swcomp/Benchmarks/BenchmarkGroup.swift +++ b/Sources/swcomp/Benchmarks/BenchmarkGroup.swift @@ -4,6 +4,7 @@ // See LICENSE for license information import Foundation +import SWCompression import SwiftCLI class BenchmarkGroup: CommandGroup { @@ -14,3 +15,99 @@ class BenchmarkGroup: CommandGroup { let children: [Routable] = [UnGzip(), UnXz(), UnBz2(), InfoTar(), InfoZip(), Info7z(), CompDeflate(), CompBz2(), CreateTar()] } + +class CompBz2: BenchmarkCommand { + + let name = "comp-bz2" + let shortDescription = "BZip2 compression" + + let inputs = CollectedParameter() + + let benchmarkName = "BZip2 Compression" + let benchmarkFunction: (Data) throws -> Any = BZip2.compress + +} + +class CompDeflate: BenchmarkCommand { + + let name = "comp-deflate" + let shortDescription = "Deflate compression" + + let inputs = CollectedParameter() + + let benchmarkName = "Deflate Compression" + let benchmarkFunction: (Data) throws -> Any = Deflate.compress + +} + +class Info7z: BenchmarkCommand { + + let name = "info-7z" + let shortDescription = "7-Zip info function" + + let inputs = CollectedParameter() + + let benchmarkName = "7-Zip info function" + let benchmarkFunction: (Data) throws -> Any = SevenZipContainer.info + +} + +class InfoTar: BenchmarkCommand { + + let name = "info-tar" + let shortDescription = "TAR info function" + + let inputs = CollectedParameter() + + let benchmarkName = "TAR info function" + let benchmarkFunction: (Data) throws -> Any = TarContainer.info + +} + +class InfoZip: BenchmarkCommand { + + let name = "info-zip" + let shortDescription = "ZIP info function" + + let inputs = CollectedParameter() + + let benchmarkName = "ZIP info function" + let benchmarkFunction: (Data) throws -> Any = ZipContainer.info + +} + +class UnBz2: BenchmarkCommand { + + let name = "un-bz2" + let shortDescription = "BZip2 unarchiving" + + let inputs = CollectedParameter() + + let benchmarkName = "BZip2 Unarchive" + let benchmarkFunction: (Data) throws -> Any = BZip2.decompress + +} + +class UnGzip: BenchmarkCommand { + + let name = "un-gzip" + let shortDescription = "GZip unarchiving" + + let inputs = CollectedParameter() + + let benchmarkName = "GZip Unarchive" + let benchmarkFunction: (Data) throws -> Any = GzipArchive.unarchive + +} + +class UnXz: BenchmarkCommand { + + let name = "un-xz" + let shortDescription = "XZ unarchiving" + + let inputs = CollectedParameter() + + let benchmarkName = "XZ Unarchive" + let benchmarkFunction: (Data) throws -> Any = XZArchive.unarchive + +} diff --git a/Sources/swcomp/Benchmarks/CompBz2.swift b/Sources/swcomp/Benchmarks/CompBz2.swift deleted file mode 100644 index a157fcd4..00000000 --- a/Sources/swcomp/Benchmarks/CompBz2.swift +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (c) 2021 Timofey Solomko -// Licensed under MIT License -// -// See LICENSE for license information - -import Foundation -import SWCompression -import SwiftCLI - -class CompBz2: BenchmarkCommand { - - let name = "comp-bz2" - let shortDescription = "BZip2 compression" - - let inputs = CollectedParameter() - - let benchmarkName = "BZip2 Compression" - let benchmarkFunction: (Data) throws -> Any = BZip2.compress - -} diff --git a/Sources/swcomp/Benchmarks/CompDeflate.swift b/Sources/swcomp/Benchmarks/CompDeflate.swift deleted file mode 100644 index 8f86d405..00000000 --- a/Sources/swcomp/Benchmarks/CompDeflate.swift +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (c) 2021 Timofey Solomko -// Licensed under MIT License -// -// See LICENSE for license information - -import Foundation -import SWCompression -import SwiftCLI - -class CompDeflate: BenchmarkCommand { - - let name = "comp-deflate" - let shortDescription = "Deflate compression" - - let inputs = CollectedParameter() - - let benchmarkName = "Deflate Compression" - let benchmarkFunction: (Data) throws -> Any = Deflate.compress - -} diff --git a/Sources/swcomp/Benchmarks/Info7z.swift b/Sources/swcomp/Benchmarks/Info7z.swift deleted file mode 100644 index bee7b041..00000000 --- a/Sources/swcomp/Benchmarks/Info7z.swift +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (c) 2021 Timofey Solomko -// Licensed under MIT License -// -// See LICENSE for license information - -import Foundation -import SWCompression -import SwiftCLI - -class Info7z: BenchmarkCommand { - - let name = "info-7z" - let shortDescription = "7-Zip info function" - - let inputs = CollectedParameter() - - let benchmarkName = "7-Zip info function" - let benchmarkFunction: (Data) throws -> Any = SevenZipContainer.info - -} diff --git a/Sources/swcomp/Benchmarks/InfoTar.swift b/Sources/swcomp/Benchmarks/InfoTar.swift deleted file mode 100644 index 9e348aae..00000000 --- a/Sources/swcomp/Benchmarks/InfoTar.swift +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (c) 2021 Timofey Solomko -// Licensed under MIT License -// -// See LICENSE for license information - -import Foundation -import SWCompression -import SwiftCLI - -class InfoTar: BenchmarkCommand { - - let name = "info-tar" - let shortDescription = "TAR info function" - - let inputs = CollectedParameter() - - let benchmarkName = "TAR info function" - let benchmarkFunction: (Data) throws -> Any = TarContainer.info - -} diff --git a/Sources/swcomp/Benchmarks/InfoZip.swift b/Sources/swcomp/Benchmarks/InfoZip.swift deleted file mode 100644 index 7155e6db..00000000 --- a/Sources/swcomp/Benchmarks/InfoZip.swift +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (c) 2021 Timofey Solomko -// Licensed under MIT License -// -// See LICENSE for license information - -import Foundation -import SWCompression -import SwiftCLI - -class InfoZip: BenchmarkCommand { - - let name = "info-zip" - let shortDescription = "ZIP info function" - - let inputs = CollectedParameter() - - let benchmarkName = "ZIP info function" - let benchmarkFunction: (Data) throws -> Any = ZipContainer.info - -} diff --git a/Sources/swcomp/Benchmarks/UnBz2.swift b/Sources/swcomp/Benchmarks/UnBz2.swift deleted file mode 100644 index 44879e1d..00000000 --- a/Sources/swcomp/Benchmarks/UnBz2.swift +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (c) 2021 Timofey Solomko -// Licensed under MIT License -// -// See LICENSE for license information - -import Foundation -import SWCompression -import SwiftCLI - -class UnBz2: BenchmarkCommand { - - let name = "un-bz2" - let shortDescription = "BZip2 unarchiving" - - let inputs = CollectedParameter() - - let benchmarkName = "BZip2 Unarchive" - let benchmarkFunction: (Data) throws -> Any = BZip2.decompress - -} diff --git a/Sources/swcomp/Benchmarks/UnGzip.swift b/Sources/swcomp/Benchmarks/UnGzip.swift deleted file mode 100644 index a558e887..00000000 --- a/Sources/swcomp/Benchmarks/UnGzip.swift +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (c) 2021 Timofey Solomko -// Licensed under MIT License -// -// See LICENSE for license information - -import Foundation -import SWCompression -import SwiftCLI - -class UnGzip: BenchmarkCommand { - - let name = "un-gzip" - let shortDescription = "GZip unarchiving" - - let inputs = CollectedParameter() - - let benchmarkName = "GZip Unarchive" - let benchmarkFunction: (Data) throws -> Any = GzipArchive.unarchive - -} diff --git a/Sources/swcomp/Benchmarks/UnXz.swift b/Sources/swcomp/Benchmarks/UnXz.swift deleted file mode 100644 index 45623fb0..00000000 --- a/Sources/swcomp/Benchmarks/UnXz.swift +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (c) 2021 Timofey Solomko -// Licensed under MIT License -// -// See LICENSE for license information - -import Foundation -import SWCompression -import SwiftCLI - -class UnXz: BenchmarkCommand { - - let name = "un-xz" - let shortDescription = "XZ unarchiving" - - let inputs = CollectedParameter() - - let benchmarkName = "XZ Unarchive" - let benchmarkFunction: (Data) throws -> Any = XZArchive.unarchive - -}