Skip to content

Commit

Permalink
Arguments: WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
kosyloa committed Oct 19, 2023
1 parent cfb3427 commit 7e21218
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 44 deletions.
10 changes: 7 additions & 3 deletions DXFeedFramework.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@
64D8BB452A39BB730071BC88 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 64D8BB432A39BB730071BC88 /* Main.storyboard */; };
64D8BB472A39BB740071BC88 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 64D8BB462A39BB740071BC88 /* Assets.xcassets */; };
64D8BB4A2A39BB740071BC88 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 64D8BB482A39BB740071BC88 /* LaunchScreen.storyboard */; };
64D8C9522AE17739009E4799 /* Arguments.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64D8C9512AE17739009E4799 /* Arguments.swift */; };
64DA26B62AA1EF47005B1757 /* DXProfileIterator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64DA26B52AA1EF47005B1757 /* DXProfileIterator.swift */; };
64DA26B82AA20095005B1757 /* NativeInstrumentProfileConnection.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64DA26B72AA20095005B1757 /* NativeInstrumentProfileConnection.swift */; };
64DA26BA2AA20AAA005B1757 /* DXInstrumentProfileConnectionState.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64DA26B92AA20AAA005B1757 /* DXInstrumentProfileConnectionState.swift */; };
Expand Down Expand Up @@ -779,6 +780,7 @@
64D8BB462A39BB740071BC88 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
64D8BB492A39BB740071BC88 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
64D8BB4B2A39BB740071BC88 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
64D8C9512AE17739009E4799 /* Arguments.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Arguments.swift; sourceTree = "<group>"; };
64DA26B52AA1EF47005B1757 /* DXProfileIterator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DXProfileIterator.swift; sourceTree = "<group>"; };
64DA26B72AA20095005B1757 /* NativeInstrumentProfileConnection.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NativeInstrumentProfileConnection.swift; sourceTree = "<group>"; };
64DA26B92AA20AAA005B1757 /* DXInstrumentProfileConnectionState.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DXInstrumentProfileConnectionState.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -931,6 +933,8 @@
children = (
64148B6E2ABB5C4A0063110E /* PerfTestCL.entitlements */,
64148B662ABB5C320063110E /* main.swift */,
64D8C9512AE17739009E4799 /* Arguments.swift */,
647426AC2ABC85F20012F793 /* ArgumentParser.swift */,
647426A62ABC7F080012F793 /* ConnectEventListener.swift */,
645BE8532AC3229D0028243D /* ToolsCommand.swift */,
641BDD572AC71CCE00236B78 /* LatencyTestCommand.swift */,
Expand Down Expand Up @@ -1165,7 +1169,6 @@
6469F8CB2A3B2F1200846831 /* MetricCell.swift */,
646D19E02A3C970700C82315 /* DXFTimer.swift */,
646979712A3B5AF60003A9BA /* Colors.xcassets */,
647426AC2ABC85F20012F793 /* ArgumentParser.swift */,
647426AE2ABC93900012F793 /* EventCode+String.swift */,
649282E62AD54919008F0F04 /* ScheduleUtils.swift */,
);
Expand Down Expand Up @@ -1977,6 +1980,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
64D8C9522AE17739009E4799 /* Arguments.swift in Sources */,
648BD56D2AC56A04004A3A95 /* SubscriptionUtils.swift in Sources */,
648BD56B2AC4576F004A3A95 /* HelpCommand.swift in Sources */,
649282E82AD54919008F0F04 /* ScheduleUtils.swift in Sources */,
Expand Down Expand Up @@ -2869,7 +2873,7 @@
INFOPLIST_KEY_UIMainStoryboardFile = Main;
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand Down Expand Up @@ -2900,7 +2904,7 @@
INFOPLIST_KEY_UIMainStoryboardFile = Main;
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,6 @@ Cmd \(cmd) contains not enough \(cmd.count - 1) arguments. Expected \(requiredNu
// 0 Arg is path to executed app
return Array(cmd[1..<cmd.count])
}


}
65 changes: 65 additions & 0 deletions Samples/PerfTestCL/Arguments.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
//
// Arguments.swift
// Tools
//
// Created by Aleksey Kosylo on 19.10.23.
//

import Foundation
import DXFeedFramework

class Arguments {

let arguments: [String]
let symbolPosition: Int

init(arguments: [String], symbolPosition: Int) {
self.arguments = arguments
self.symbolPosition = symbolPosition
}



func parseSymbols() -> [String] {
let symbols = arguments[symbolPosition]
var symbolsList = [String]()
func addSymbol(str: String) {
if str.hasPrefix("ipf[") && str.hasSuffix("]") {
if let address = str.slice(from: "[", to: "]") {
let profiles = try? DXInstrumentProfileReader().readFromFile(address: address)
profiles?.forEach({ profile in
symbolsList.append(profile.symbol)
})
}
} else {
symbolsList.append(str)
}
}
var parentheses = 0
var tempSrting = ""
symbols.forEach { character in
switch character {
case "{", "(", "[":
parentheses += 1
tempSrting.append(character)
case "}", ")", "]":
if parentheses > 0 {
parentheses -= 1
}
tempSrting.append(character)
case ",":
if parentheses == 0 {
addSymbol(str: tempSrting)
tempSrting = ""
} else {
tempSrting.append(character)
}
default:
tempSrting.append(character)
}
}

addSymbol(str: tempSrting)
return symbolsList
}
}
42 changes: 2 additions & 40 deletions Samples/PerfTestCL/ConnectCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,50 +53,12 @@ Where:
let address = arguments[1]
let types = arguments[2]

let symbols = arguments[3]
var symbolsList = [String]()
func addSymbol(str: String) {
if str.hasPrefix("ipf[") && str.hasSuffix("]") {
if let address = str.slice(from: "[", to: "]") {
let profiles = try? DXInstrumentProfileReader().readFromFile(address: address)
profiles?.forEach({ profile in
symbolsList.append(profile.symbol)
})
}
} else {
symbolsList.append(str)
}
}
var parentheses = 0
var tempSrting = ""
symbols.forEach { character in
switch character {
case "{", "(", "[":
parentheses += 1
tempSrting.append(character)
case "}", ")", "]":
if parentheses > 0 {
parentheses -= 1
}
tempSrting.append(character)
case ",":
if parentheses == 0 {
addSymbol(str: tempSrting)
tempSrting = ""
} else {
tempSrting.append(character)
}
default:
tempSrting.append(character)
}
}

addSymbol(str: tempSrting)
var time: String?
if arguments.count > 4 {
time = arguments[4]
}

let argumentsObj = Arguments(arguments: arguments, symbolPosition: 3)
let symbolsList = argumentsObj.parseSymbols()
let listener = ConnectEventListener()
subscription.createSubscription(address: address,
symbols: symbolsList,
Expand Down
3 changes: 2 additions & 1 deletion Samples/PerfTestCL/DumpCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ class DumpCommand: ToolsCommand {
}
let address = arguments[1]
let types = arguments[2]
let symbols = arguments[3].components(separatedBy: ",")
let argumentsObj = Arguments(arguments: arguments, symbolPosition: 3)
let symbols = argumentsObj.parseSymbols()

var tapeFile: String?
if let tapeIndex = arguments.firstIndex(of: "-t") {
Expand Down

0 comments on commit 7e21218

Please sign in to comment.