Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
AlfengYuan committed Jan 17, 2024
1 parent 7b30851 commit 4c8bd56
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 11 deletions.
20 changes: 14 additions & 6 deletions sophon-app/src/resnet50_sail_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "MQTTClient.h"
#include <ctime>
#include <iostream>

#include <unistd.h>
#include <fstream>
#include <vector>
#include <string>
Expand Down Expand Up @@ -484,6 +484,7 @@ int main(int argc, char *argv[]) {
bool status = true;
int ret = 0;
//load bmodel and do inference
auto start = std::chrono::steady_clock::now();
while (1) {
for (size_t i = 0; i < mycameras.size(); i++) {

Expand Down Expand Up @@ -514,14 +515,21 @@ int main(int argc, char *argv[]) {

if(mycameras[i].state == SQSY::NORMAL) continue;

// minio upload
ret = Minio_File_Upload(mycameras[i], out_timesnap, sncode);
auto end = std::chrono::steady_clock::now();
auto tt = std::chrono::duration_cast<std::chrono::seconds>(end - start);
if(tt.count() > 900) {
// minio upload
ret = Minio_File_Upload(mycameras[i], out_timesnap, sncode);

if (ret == 0) {
// MQTTMessage publish
MQTT_PubMessage(mycameras[i], out_timesnap, sncode);
}

if (ret == 0) {
// MQTTMessage publish
MQTT_PubMessage(mycameras[i], out_timesnap, sncode);
start = std::chrono::steady_clock::now();
}


// Destory old images
destroy_old_images("results/images/");
}
Expand Down
12 changes: 7 additions & 5 deletions sophon-app/test/cpp/c11_chrono_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <string>
#include <ctime>
#include <chrono>
#include <unistd.h>
using namespace std::chrono;
using namespace std;

Expand All @@ -22,11 +23,12 @@ int main()

// duration
auto start = std::chrono::steady_clock::now();
for(int i = 0; i<100; i++) cout << "nice" << endl;
for(int i = 0; i<100000; i++) cout << "nice" << endl;
sleep(11);
auto end = std::chrono::steady_clock::now();
auto tt = std::chrono::duration_cast<microseconds>(end - start);

cout << "program time = " << tt.count() << "microseconds" << endl;

auto tt = std::chrono::duration_cast<seconds>(end - start);
if(tt.count() > 10){
cout << "program time = " << tt.count() << "microseconds" << endl;
}
return 0;
}

0 comments on commit 4c8bd56

Please sign in to comment.