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

Prepare Move to swift-extras #21

Merged
merged 2 commits into from
Nov 12, 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
8 changes: 4 additions & 4 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
- name: Test
run: swift test --enable-code-coverage --enable-test-discovery
- name: Convert coverage files
run: llvm-cov export -format="lcov" .build/debug/swift-base64-kitPackageTests.xctest -instr-profile .build/debug/codecov/default.profdata > info.lcov
run: llvm-cov export -format="lcov" .build/debug/swift-extras-base64PackageTests.xctest -instr-profile .build/debug/codecov/default.profdata > info.lcov
- name: Install curl
if: matrix.images != 'swiftlang/swift:nightly-amazonlinux2'
run: apt-get update && apt-get install -y curl # required by the codecov action.
Expand Down Expand Up @@ -90,7 +90,7 @@ jobs:
fail-fast: false
matrix:
xcode:
- Xcode_11.1.app
- Xcode_11.2.app
- Xcode_11.6.app
- Xcode_12.2.app
steps:
Expand All @@ -107,7 +107,7 @@ jobs:
- name: Xcode Tests
run: |
swift package generate-xcodeproj
xcodebuild -quiet -parallel-testing-enabled YES -scheme swift-base64-kit-Package -enableCodeCoverage YES build test
xcodebuild -quiet -parallel-testing-enabled YES -scheme swift-extras-base64-Package -enableCodeCoverage YES build test
- name: Codecov
run: bash <(curl -s https://codecov.io/bash) -t ${{secrets.CODECOV_TOKEN}} -f *.coverage.txt

Expand All @@ -117,7 +117,7 @@ jobs:
fail-fast: false
matrix:
xcode:
- Xcode_11.1.app
- Xcode_11.2.app
- Xcode_11.6.app
- Xcode_12.2.app
steps:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ fi

"$here/../../allocation-counter-tests-framework/run-allocation-counter.sh" \
-p "$here/../../.." \
-m Base64Kit \
-m ExtrasBase64 \
-s "$here/shared.swift" \
-t "$tmp_dir" \
"${tests_to_run[@]}"
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Base64Kit
import ExtrasBase64

func run(identifier: String) {
let base64 = "AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fn+AgYKDhIWGh4iJiouMjY6PkJGSk5SVlpeYmZqbnJ2en6ChoqOkpaanqKmqq6ytrq+wsbKztLW2t7i5uru8vb6/wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX2Nna29zd3t/g4eLj5OXm5+jp6uvs7e7v8PHy8/T19vf4+fr7/P3+/w=="
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Base64Kit
import ExtrasBase64

func run(identifier: String) {
let bytes = Array(UInt8(0) ... UInt8(255))
Expand Down
10 changes: 5 additions & 5 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
import PackageDescription

let package = Package(
name: "swift-base64-kit",
name: "swift-extras-base64",
products: [
.library(name: "Base64Kit", targets: ["Base64Kit"]),
.library(name: "ExtrasBase64", targets: ["ExtrasBase64"]),
],
dependencies: [],
targets: [
.target(name: "Base64Kit", dependencies: []),
.target(name: "PerformanceTest", dependencies: ["Base64Kit"]),
.testTarget(name: "Base64KitTests", dependencies: ["Base64Kit"]),
.target(name: "ExtrasBase64", dependencies: []),
.target(name: "PerformanceTest", dependencies: ["ExtrasBase64"]),
.testTarget(name: "ExtrasBase64Tests", dependencies: ["ExtrasBase64"]),
]
)
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# swift-base64-kit
# swift-extras-base64

[![Swift 5.1](https://img.shields.io/badge/Swift-5.1-blue.svg)](https://swift.org/download/)
[![github-actions](https://github.com/fabianfett/swift-base64-kit/workflows/CI/badge.svg)](https://github.com/fabianfett/swift-base64-kit/actions)
[![codecov](https://codecov.io/gh/fabianfett/swift-base64-kit/branch/main/graph/badge.svg)](https://codecov.io/gh/fabianfett/swift-base64)
[![github-actions](https://github.com/swift-extras/swift-extras-base64/workflows/CI/badge.svg)](https://github.com/swift-extras/swift-extras-base64/actions)
[![codecov](https://codecov.io/gh/swift-extras/swift-extras-base64/branch/main/graph/badge.svg)](https://codecov.io/gh/swift-extras/swift-extras-base64)
![macOS](https://img.shields.io/badge/os-macOS-green.svg?style=flat)
![tuxOS](https://img.shields.io/badge/os-tuxOS-green.svg?style=flat)

Expand All @@ -23,7 +23,7 @@ A former implementation of this package [is used in `swift-nio`'s websocket impl

## Performance

Super [simple performance test](https://github.com/fabianfett/swift-base64-kit/blob/main/Sources/Base64KitPerformanceTest/main.swift)
Super [simple performance test](https://github.com/swift-extras/swift-extras-base64/blob/main/Sources/PerformanceTest/main.swift)
to ensure speediness of this implementation. Encoding and decoding 1m times the base64 string:

```
Expand All @@ -37,15 +37,15 @@ Tests were run on a MacBook Pro (16-inch, late 2019). Processor: 2.4 GHz 8-Core
| | Encoding | Decoding |
|:--|:--|:--|
| Foundation | 2.08s | 2.15s |
| swift-base64-kit | 0.66s | 0.54s |
| swift-extras-base64 | 0.66s | 0.54s |
| Speedup | 3x | 4x |

#### Linux - swift 5.3

| | Encoding | Decoding |
|:--|:--|:--|
| Foundation | 1.01s | 5.5s |
| swift-base64-kit | 0.27s | 0.41s |
| swift-extras-base64 | 0.27s | 0.41s |
| Speedup | 3x | **~10x** |

## Literature for a faster algorithm
Expand Down
File renamed without changes.
File renamed without changes.
25 changes: 1 addition & 24 deletions Sources/PerformanceTest/main.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Base64Kit
import ExtrasBase64
import Foundation

let base64 = "AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fn+AgYKDhIWGh4iJiouMjY6PkJGSk5SVlpeYmZqbnJ2en6ChoqOkpaanqKmqq6ytrq+wsbKztLW2t7i5uru8vb6/wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX2Nna29zd3t/g4eLj5OXm5+jp6uvs7e7v8PHy8/T19vf4+fr7/P3+/w=="
Expand Down Expand Up @@ -85,26 +85,3 @@ let chromeDecodingFromData = timing(name: "Chromium: Data to [UInt8]") {
_ = try! Base64.decode(bytes: encodedData)
}
}

// print("------------------------------------------")
// print("Results")

var result: Int32 = 0
// if foundationEncoding < base64Encoding {
// print("Base64 encoding must be at least as fast as Foundation encoding")
// result = 1
// }
//
// if foundationDecoding < base64Decoding {
// print("Base64 decoding must be at least as fast as Foundation decoding")
// result = 1
// }
//
// if result == 0 {
// let encodingGain = round(foundationEncoding / base64Encoding * 1000) / 1000
// let decodingGain = round(foundationDecoding / base64Decoding * 1000) / 1000
// print("Encoding: \(encodingGain)x")
// print("Decoding: \(decodingGain)x")
// }

exit(result)
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Base64Kit
import ExtrasBase64
import XCTest

class ChromiumTests: XCTestCase {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@testable import Base64Kit
@testable import ExtrasBase64
import XCTest

class IntegrationTests: XCTestCase {
Expand Down