Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/wolfpld/tracy.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGraydon Hoare <graydon@pobox.com>2021-08-26 08:22:58 +0300
committerGraydon Hoare <graydon@pobox.com>2021-08-26 08:52:23 +0300
commit26fd867e52fcb4307ebf41e28f87a608c3c56a84 (patch)
tree724105aa5736ef61a22cca4d2c707e5e0bae108a /capture
parentdfb4020a924e45e44eaaffb952afb822b2b8acea (diff)
Add `-s <seconds>` parameter to capture.cpp
Diffstat (limited to 'capture')
-rw-r--r--capture/src/capture.cpp17
1 files changed, 15 insertions, 2 deletions
diff --git a/capture/src/capture.cpp b/capture/src/capture.cpp
index 749c3579..184aeb60 100644
--- a/capture/src/capture.cpp
+++ b/capture/src/capture.cpp
@@ -34,7 +34,7 @@ void SigInt( int )
[[noreturn]] void Usage()
{
- printf( "Usage: capture -o output.tracy [-a address] [-p port] [-f]\n" );
+ printf( "Usage: capture -o output.tracy [-a address] [-p port] [-f] [-s seconds]\n" );
exit( 1 );
}
@@ -52,9 +52,10 @@ int main( int argc, char** argv )
const char* address = "127.0.0.1";
const char* output = nullptr;
int port = 8086;
+ int seconds = -1;
int c;
- while( ( c = getopt( argc, argv, "a:o:p:f" ) ) != -1 )
+ while( ( c = getopt( argc, argv, "a:o:p:fs:" ) ) != -1 )
{
switch( c )
{
@@ -70,6 +71,9 @@ int main( int argc, char** argv )
case 'f':
overwrite = true;
break;
+ case 's':
+ seconds = atoi (optarg);
+ break;
default:
Usage();
break;
@@ -137,6 +141,7 @@ int main( int argc, char** argv )
{
worker.Disconnect();
disconnect = false;
+ break;
}
lock.lock();
@@ -162,6 +167,14 @@ int main( int argc, char** argv )
fflush( stdout );
std::this_thread::sleep_for( std::chrono::milliseconds( 100 ) );
+ if( seconds != -1 )
+ {
+ const auto dur = std::chrono::high_resolution_clock::now() - t0;
+ if( std::chrono::duration_cast<std::chrono::seconds>(dur).count() >= seconds )
+ {
+ disconnect = true;
+ }
+ }
}
const auto t1 = std::chrono::high_resolution_clock::now();