Skip to content

Commit

Permalink
try fix
Browse files Browse the repository at this point in the history
  • Loading branch information
albho committed Nov 23, 2024
1 parent d92a8fa commit 8e542b4
Show file tree
Hide file tree
Showing 9 changed files with 150 additions and 119 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ios-browserstack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ jobs:
- name: Make build dir
run: mkdir ddp

- name: Copy test_resources
run: ./copy_test_resources.sh

- name: Run Cocoapods
run: pod install

Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/ios-perf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ jobs:
- name: Make build dir
run: mkdir ddp

- name: Copy test_resources
run: ./copy_test_resources.sh

- name: Run Cocoapods
run: pod install

Expand Down
4 changes: 3 additions & 1 deletion binding/ios/EagleAppTest/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@ build/*
*.pbxuser
xcuserdata
Pods
ddp
ddp

EagleAppTestUITests/test_resources/audio_samples/*
207 changes: 104 additions & 103 deletions binding/ios/EagleAppTest/EagleAppTest.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,18 @@ class EagleAppTestUITests: BaseTest {

private func imposterUrl() -> URL {
let bundle = Bundle(for: type(of: self))
return bundle.url(forResource: "speaker_2_test_utt", withExtension: "wav", subdirectory: "audio_samples")!
return bundle.url(
forResource: "speaker_2_test_utt",
withExtension: "wav",
subdirectory: "audio_samples")!
}

private func testUrl() -> URL {
let bundle = Bundle(for: type(of: self))
return bundle.url(forResource: "speaker_1_test_utt", withExtension: "wav", subdirectory: "audio_samples")!
return bundle.url(
forResource: "speaker_1_test_utt",
withExtension: "wav",
subdirectory: "audio_samples")!
}

private func initEagle() throws -> Eagle {
Expand Down
Empty file.
30 changes: 18 additions & 12 deletions binding/ios/EagleAppTest/PerformanceTest/PerformanceTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,17 @@ class PerformanceTest: XCTestCase {
}

func testProfilerPerformance() throws {
try XCTSkipIf(indexThresholdString == "{ENROLL_PERFORMANCE_THRESHOLD_SEC}")
try XCTSkipIf(enrollThresholdString == "{ENROLL_PERFORMANCE_THRESHOLD_SEC}")

let numTestIterations = Int(iterationString) ?? 30
let indexPerformanceThresholdSec = Double(indexThresholdString)
try XCTSkipIf(indexPerformanceThresholdSec == nil)
let enrollPerformanceThresholdSec = Double(enrollThresholdString)
try XCTSkipIf(enrollPerformanceThresholdSec == nil)

let bundle = Bundle(for: type(of: self))
let fileURL: URL = bundle.url(forResource: "test", withExtension: "wav")!
let fileURL: URL = bundle.url(
forResource: "speaker_1_test_utt",
withExtension: "wav",
subdirectory: "audio_samples")!
let audioData = try Data(contentsOf: fileURL)
var pcm = [Int16](repeating: 0, count: (audioData.count - 44) / 2)
_ = pcm.withUnsafeMutableBytes {
Expand All @@ -54,21 +57,21 @@ class PerformanceTest: XCTestCase {

let avgNSec = results.reduce(0.0, +) / Double(numTestIterations)
let avgSec = Double(round(avgNSec * 1000) / 1000)
XCTAssertLessThanOrEqual(avgSec, indexPerformanceThresholdSec!)
XCTAssertLessThanOrEqual(avgSec, enrollPerformanceThresholdSec!)
}

func testProcPerformance() throws {
try XCTSkipIf(searchThresholdString == "{PROC_PERFORMANCE_THRESHOLD_SEC}")
try XCTSkipIf(procThresholdString == "{PROC_PERFORMANCE_THRESHOLD_SEC}")

let numTestIterations = Int(iterationString) ?? 30
let searchPerformanceThresholdSec = Double(searchThresholdString)
try XCTSkipIf(searchPerformanceThresholdSec == nil)
let procPerformanceThresholdSec = Double(procThresholdString)
try XCTSkipIf(procPerformanceThresholdSec == nil)

let bundle = Bundle(for: type(of: self))

let enrollUrls: [URL] = [
bundle.url(forResource: "speaker_1_utt_1", withExtension: "wav")!,
bundle.url(forResource: "speaker_1_utt_2", withExtension: "wav")!
bundle.url(forResource: "speaker_1_utt_1", withExtension: "wav", subdirectory: "audio_samples")!,
bundle.url(forResource: "speaker_1_utt_2", withExtension: "wav", subdirectory: "audio_samples")!
]
let eagleProfiler = try EagleProfiler(accessKey: accessKey)
for enrollUrl in enrollUrls {
Expand All @@ -83,7 +86,10 @@ class PerformanceTest: XCTestCase {
let profile = try eagleProfiler.export()
eagleProfiler.delete()

let testAudioURL: URL = bundle.url(forResource: "test", withExtension: "wav")!
let testAudioURL: URL = bundle.url(
forResource: "speaker_2_test_utt",
withExtension: "wav",
subdirectory: "audio_samples")!
let audioData = try Data(contentsOf: testAudioURL)
var pcm = [Int16](repeating: 0, count: (audioData.count - 44) / 2)
_ = pcm.withUnsafeMutableBytes {
Expand All @@ -106,6 +112,6 @@ class PerformanceTest: XCTestCase {

let avgNSec = results.reduce(0.0, +) / Double(numTestIterations)
let avgSec = Double(round(avgNSec * 1000) / 1000)
XCTAssertLessThanOrEqual(avgSec, searchPerformanceThresholdSec!)
XCTAssertLessThanOrEqual(avgSec, procPerformanceThresholdSec!)
}
}
2 changes: 1 addition & 1 deletion binding/ios/EagleAppTest/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ SPEC CHECKSUMS:

PODFILE CHECKSUM: 32252195e8a4e7b7e29caf8a647533d7585f75e0

COCOAPODS: 1.11.3
COCOAPODS: 1.16.2
10 changes: 10 additions & 0 deletions binding/ios/EagleAppTest/copy_test_resources.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
LIB_DIR="../../../lib"
RESOURCE_DIR="../../../resources"
ASSETS_DIR="./EagleAppTestUITests/test_resources"

echo "Creating test resources asset directory"
mkdir -p ${ASSETS_DIR}

echo "Copying test audio samples..."
mkdir -p ${ASSETS_DIR}/audio_samples
cp ${RESOURCE_DIR}/audio_samples/*.wav ${ASSETS_DIR}/audio_samples

0 comments on commit 8e542b4

Please sign in to comment.