mirror of
https://github.com/apple/swift-nio
synced 2026-11-25 04:47:49 +00:00
Motivation: In Swift, it's really easy to accidentally add allocations yet the number of allocations is really important for performance. Therefore it's useful to have an integration test that counts the number of allocations and compares them to a reference (and fails if the number of allocations increases). Modifications: - add an allocation counter - add a HTTP1 client/server example that is run with the allocation counter intrumentation Result: We should now be able to track the number of allocations.
67 lines
1.6 KiB
Bash
67 lines
1.6 KiB
Bash
#!/bin/bash
|
|
##===----------------------------------------------------------------------===##
|
|
##
|
|
## This source file is part of the SwiftNIO open source project
|
|
##
|
|
## Copyright (c) 2017-2018 Apple Inc. and the SwiftNIO project authors
|
|
## Licensed under Apache License v2.0
|
|
##
|
|
## See LICENSE.txt for license information
|
|
## See CONTRIBUTORS.txt for the list of SwiftNIO project authors
|
|
##
|
|
## SPDX-License-Identifier: Apache-2.0
|
|
##
|
|
##===----------------------------------------------------------------------===##
|
|
function fail() {
|
|
echo >&2 "FAILURE: $*"
|
|
false
|
|
}
|
|
|
|
function assert_equal() {
|
|
if [[ "$1" != "$2" ]]; then
|
|
fail "expected '$1', got '$2' ${3-}"
|
|
fi
|
|
}
|
|
|
|
function assert_equal_files() {
|
|
if ! cmp -s "$1" "$2"; then
|
|
diff -u "$1" "$2" || true
|
|
echo
|
|
echo "--- SNIP ($1, size=$(wc "$1"), SHA=$(shasum "$1")) ---"
|
|
cat "$1"
|
|
echo "--- SNAP ($1)---"
|
|
echo "--- SNIP ($2, size=$(wc "$2"), SHA=$(shasum "$2")) ---"
|
|
cat "$2"
|
|
echo "--- SNAP ($2) ---"
|
|
fail "file '$1' not equal to '$2'"
|
|
fi
|
|
}
|
|
|
|
function assert_less_than() {
|
|
if [[ ! "$1" -lt "$2" ]]; then
|
|
fail "assertion '$1' < '$2' failed"
|
|
fi
|
|
}
|
|
|
|
function assert_less_than_or_equal() {
|
|
if [[ ! "$1" -le "$2" ]]; then
|
|
fail "assertion '$1' <= '$2' failed"
|
|
fi
|
|
}
|
|
|
|
function assert_greater_than() {
|
|
if [[ ! "$1" -gt "$2" ]]; then
|
|
fail "assertion '$1' > '$2' failed"
|
|
fi
|
|
}
|
|
|
|
function assert_greater_than_or_equal() {
|
|
if [[ ! "$1" -ge "$2" ]]; then
|
|
fail "assertion '$1' >= '$2' failed"
|
|
fi
|
|
}
|
|
|
|
function warn() {
|
|
echo >&4 "warning: $*"
|
|
}
|