зеркало из
1
0
Форкнуть 0

Update memory information for reporter

This commit is contained in:
Jelani 2018-09-14 14:27:34 -07:00
Родитель 859d78ff7c
Коммит 708c507e06
11 изменённых файлов: 210 добавлений и 106 удалений

Просмотреть файл

@ -8,6 +8,7 @@ include("configs/analysisFunctions.cmake")
set(TARGET_GIT_BRANCH "master" CACHE STRING "Branch of the SDK repo to target`")
set(no_logging ON)
set(use_mqtt ON)
set(use_amqp OFF)
set(use_http OFF)
@ -29,6 +30,13 @@ include(ExternalProject)
message("Generated with config types: ${CMAKE_CONFIGURATION_TYPES}")
if(${no_logging})
add_definitions(-DNO_LOGGING)
endif()
if (${dont_use_uploadtoblob})
add_definitions(-DDONT_USE_UPLOADTOBLOB)
endif()
# load the c-sdk
#SET(CMAKE_BUILD_TYPE Release)
#set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -Wall")
@ -67,5 +75,5 @@ set(SDK_CERT_INCLUDE_DIRS
)
set(REPORTER_DIR ${CMAKE_CURRENT_LIST_DIR})
#add_subdirectory(memory)
add_subdirectory(memory)
add_analytic_directory(binary_info "binary_info")

Просмотреть файл

@ -0,0 +1,11 @@
SDK Without Diagnostic
{ "sdkAnalysis": { "dateTime": "8-30-2018", "opType": "binSize", "feature": "d2c", "layer": "lower layer", "OS": "Linux", "version": "1.2.8", "transport" : "MQTT PROTOCOL", "binarySize" : "387776"} }
{ "sdkAnalysis": { "dateTime": "8-30-2018", "opType": "binSize", "feature": "d2c", "layer": "lower layer", "OS": "Linux", "version": "1.2.8", "transport" : "MQTT WS PROTOCOL", "binarySize" : "439008"} }
SDK Without Diag & Retry
{ "sdkAnalysis": { "dateTime": "8-30-2018", "opType": "binSize", "feature": "d2c", "layer": "lower layer", "OS": "Linux", "version": "1.2.8", "transport" : "MQTT PROTOCOL", "binarySize" : "379040"} }
{ "sdkAnalysis": { "dateTime": "8-30-2018", "opType": "binSize", "feature": "d2c", "layer": "lower layer", "OS": "Linux", "version": "1.2.8", "transport" : "MQTT WS PROTOCOL", "binarySize" : "434400"} }
SDK Without Methods & Twin
{ "sdkAnalysis": { "dateTime": "8-30-2018", "opType": "binSize", "feature": "d2c", "layer": "lower layer", "OS": "Linux", "version": "1.2.8", "transport" : "MQTT PROTOCOL", "binarySize" : "374456"} }
{ "sdkAnalysis": { "dateTime": "8-30-2018", "opType": "binSize", "feature": "d2c", "layer": "lower layer", "OS": "Linux", "version": "1.2.8", "transport" : "MQTT WS PROTOCOL", "binarySize" : "425680"} }

Просмотреть файл

@ -31,19 +31,30 @@ static REPORTER_TYPE g_report_type = REPORTER_TYPE_JSON;
static const char* const UNKNOWN_TYPE = "unknown";
static const char* const NODE_SDK_ANALYSIS = "sdkAnalysis";
static const char* const NODE_BASE_ARRAY = "analysisItem";
static const char* const SDK_ANALYSIS_EMPTY_NODE = "{ \"sdkAnalysis\" : { \"osType\": \"%s\", \"analysisItem\" : [] } }";
static const char* const SDK_ANALYSIS_EMPTY_NODE = "{ \"sdkAnalysis\" : { \"osType\": \"%s\", \"uploadEnabled\": \"%s\", \"logEnabled\": \"%s\", \"analysisItem\" : [] } }";
static const char* const NODE_OPERATING_SYSTEM = "osType";
static const char* const NETWORK_ANALYSIS_JSON_FMT = "{ \"type\": \"ROM\", \"dateTime\": \"%s\", \"opType\": \"%s\", \"feature\": \"%s\", \"OS\": \"%s\", \"version\": \"%s\", \"transport\" : \"%s\", \"msgPayload\" : %d, \"sendBytes\" : %" PRIu64 ", \"numSends\" : %ld, \"recvBytes\" : %" PRIu64 ", \"numRecv\" : %ld } }";
static const char* const NETWORK_ANALYSIS_CVS_FMT = "%s, %s, %s, %s, %s, %s, %d, %" PRIu64 ", %ld, %" PRIu64 ", %ld";
static const char* const BINARY_SIZE_JSON_FMT = "{ \"type\": \"ROM\", \"dateTime\": \"%s\", \"feature\": \"%s\", \"layer\": \"%s\", \"version\": \"%s\", \"transport\" : \"%s\", \"binarySize\" : \"%ld\" }";
static const char* const BINARY_SIZE_JSON_FMT = "{ \"type\": \"ROM\", \"dateTime\": \"%s\", \"feature\": \"%s\", \"layer\": \"%s\", \"version\": \"%s\", \"transport\" : \"%s\", \"binarySize\" : \"%s\" }";
static const char* const HEAP_ANALYSIS_JSON_FMT = "{ \"type\": \"RAM\", \"dateTime\": \"%s\", \"feature\": \"%s\", \"layer\": \"%s\", \"version\": \"%s\", \"transport\" : \"%s\", \"msgCount\" : %d, \"maxMemory\" : %zu, \"currMemory\" : %zu, \"numAlloc\" : %zu } }";
static const char* const BINARY_SIZE_CVS_FMT = "%s, %s, %s, %s, %s, %s, %s, %ld";
static const char* const HEAP_ANALYSIS_JSON_FMT = "{ \"sdkAnalysis\": { \"dateTime\": \"%s\", \"opType\": \"%s\", \"feature\": \"%s\", \"layer\": \"%s\", \"OS\": \"%s\", \"version\": \"%s\", \"transport\" : \"%s\", \"msgCount\" : %d, \"maxMemory\" : %zu, \"currMemory\" : %zu, \"numAlloc\" : %zu } }";
static const char* const HEAP_ANALYSIS_CVS_FMT = "%s, %s, %s, %s, %s, %s, %s, %d, %zu, %zu, %zu";
#ifdef NO_LOGGING
static const char* const LOGGING_INCLUDED = "false";
#else
static const char* const LOGGING_INCLUDED = "true";
#endif
#ifdef DONT_USE_UPLOADTOBLOB
static const char* const UPLOAD_INCLUDED = "false";
#else
static const char* const UPLOAD_INCLUDED = "true";
#endif
typedef struct REPORT_INFO_TAG
{
REPORTER_TYPE type;
@ -75,7 +86,38 @@ static void format_bytes(long bytes, char formatting[FORMAT_MAX_LEN])
}
formatting[index + extra_char] = temp[index];
}
}
static void add_node_to_json(const char* node_data, const REPORT_INFO* report_info)
{
JSON_Value* json_value;
if ((json_value = json_parse_string(node_data)) != NULL)
{
JSON_Object* json_object;
JSON_Array* base_array;
JSON_Value* json_analysis;
if ((json_analysis = json_object_get_value(report_info->analysis_node, NODE_SDK_ANALYSIS)) == NULL)
{
(void)printf("ERROR: Failed getting node object value\r\n");
}
else if ((json_object = json_value_get_object(json_analysis)) == NULL)
{
(void)printf("ERROR: Failed getting object value\r\n");
}
else if ((base_array = json_object_get_array(json_object, NODE_BASE_ARRAY)) == NULL)
{
(void)printf("ERROR: Failed getting object value\r\n");
}
else
{
if (json_array_append_value(base_array, json_value) != JSONSuccess)
{
(void)printf("ERROR: Failed to allocate binary json\r\n");
}
}
}
}
static void upload_to_azure(const char* data)
@ -201,13 +243,13 @@ static const char* get_operation_type(OPERATION_TYPE type)
return result;
}
static const char* get_format_value(OPERATION_TYPE type)
static const char* get_format_value(const REPORT_INFO* report_info, OPERATION_TYPE type)
{
const char* result;
switch (type)
{
case OPERATION_MEMORY:
if (g_report_type == REPORTER_TYPE_CVS)
if (report_info->type == REPORTER_TYPE_CVS)
{
result = HEAP_ANALYSIS_CVS_FMT;
}
@ -217,7 +259,7 @@ static const char* get_format_value(OPERATION_TYPE type)
}
break;
case OPERATION_NETWORK:
if (g_report_type == REPORTER_TYPE_CVS)
if (report_info->type == REPORTER_TYPE_CVS)
{
result = NETWORK_ANALYSIS_CVS_FMT;
}
@ -227,7 +269,7 @@ static const char* get_format_value(OPERATION_TYPE type)
}
break;
case OPERATION_BINARY_SIZE:
if (g_report_type == REPORTER_TYPE_CVS)
if (report_info->type == REPORTER_TYPE_CVS)
{
result = BINARY_SIZE_CVS_FMT;
}
@ -257,7 +299,7 @@ REPORT_HANDLE report_initialize(REPORTER_TYPE type)
result->type = type;
if (result->type == REPORTER_TYPE_JSON)
{
STRING_HANDLE json_node = STRING_construct_sprintf(SDK_ANALYSIS_EMPTY_NODE, OS_NAME);
STRING_HANDLE json_node = STRING_construct_sprintf(SDK_ANALYSIS_EMPTY_NODE, OS_NAME, UPLOAD_INCLUDED, LOGGING_INCLUDED);
if (json_node == NULL)
{
(void)printf("Failure creating Analysis node\r\n");
@ -308,13 +350,13 @@ void report_binary_sizes(REPORT_HANDLE handle, const BINARY_INFO* bin_info)
{
if (handle != NULL)
{
JSON_Value* rom_size_node;
char date_time[DATE_TIME_LEN];
char byte_formatted[FORMAT_MAX_LEN];
get_report_date(date_time, DATE_TIME_LEN);
format_bytes(bin_info->binary_size, byte_formatted);
STRING_HANDLE binary_data = STRING_construct_sprintf(BINARY_SIZE_JSON_FMT, date_time, get_feature_type(bin_info->feature_type),
const char* string_format = get_format_value(handle, bin_info->operation_type);
STRING_HANDLE binary_data = STRING_construct_sprintf(string_format, date_time, get_feature_type(bin_info->feature_type),
get_layer_type(bin_info->feature_type), bin_info->iothub_version, get_protocol_name(bin_info->iothub_protocol), byte_formatted);
if (binary_data == NULL)
{
@ -322,78 +364,62 @@ void report_binary_sizes(REPORT_HANDLE handle, const BINARY_INFO* bin_info)
}
else
{
if ((rom_size_node = json_parse_string(STRING_c_str(binary_data))) != NULL)
{
JSON_Object* json_object;
JSON_Array* base_array;
JSON_Value* json_analysis;
if ((json_analysis = json_object_get_value(handle->analysis_node, NODE_SDK_ANALYSIS)) == NULL)
{
(void)printf("ERROR: Failed getting node object value\r\n");
}
else if ((json_object = json_value_get_object(json_analysis)) == NULL)
{
(void)printf("ERROR: Failed getting object value\r\n");
}
else if ((base_array = json_object_get_array(json_object, NODE_BASE_ARRAY)) == NULL)
{
(void)printf("ERROR: Failed getting object value\r\n");
}
else
{
if (json_array_append_value(base_array, rom_size_node) != JSONSuccess)
{
(void)printf("ERROR: Failed to allocate binary json\r\n");
}
}
}
add_node_to_json(STRING_c_str(binary_data), handle);
STRING_delete(binary_data);
}
}
}
void report_memory_usage(const MEM_ANALYSIS_INFO* iot_mem_info)
void report_memory_usage(REPORT_HANDLE handle, const MEM_ANALYSIS_INFO* iot_mem_info)
{
char date_time[DATE_TIME_LEN];
get_report_date(date_time, DATE_TIME_LEN);
if (handle != NULL)
{
char date_time[DATE_TIME_LEN];
char max_use[FORMAT_MAX_LEN];
char current_mem[FORMAT_MAX_LEN];
char alloc_number[FORMAT_MAX_LEN];
get_report_date(date_time, DATE_TIME_LEN);
format_bytes(gballoc_getMaximumMemoryUsed(), max_use);
format_bytes(gballoc_getCurrentMemoryUsed(), current_mem);
format_bytes(gballoc_getAllocationCount(), alloc_number);
const char* string_format = get_format_value(iot_mem_info->operation_type);
STRING_HANDLE analysis_data = STRING_construct_sprintf(string_format, date_time, get_operation_type(iot_mem_info->operation_type), get_feature_type(iot_mem_info->feature_type), get_layer_type(iot_mem_info->feature_type), OS_NAME,
iot_mem_info->iothub_version, get_protocol_name(iot_mem_info->iothub_protocol), iot_mem_info->msg_sent, gballoc_getMaximumMemoryUsed(), gballoc_getCurrentMemoryUsed(), gballoc_getAllocationCount());
if (analysis_data == NULL)
{
(void)printf("ERROR: Failed to allocate memory json\r\n");
}
else
{
(void)printf("%s\r\n", STRING_c_str(analysis_data));
ThreadAPI_Sleep(10);
upload_to_azure(STRING_c_str(analysis_data));
STRING_delete(analysis_data);
const char* string_format = get_format_value(handle, iot_mem_info->operation_type);
STRING_HANDLE analysis_data = STRING_construct_sprintf(string_format, date_time, get_feature_type(iot_mem_info->feature_type), get_layer_type(iot_mem_info->feature_type),
iot_mem_info->iothub_version, get_protocol_name(iot_mem_info->iothub_protocol), iot_mem_info->msg_sent, max_use, gballoc_getCurrentMemoryUsed(), gballoc_getAllocationCount());
if (analysis_data == NULL)
{
(void)printf("ERROR: Failed to allocate memory json\r\n");
}
else
{
add_node_to_json(STRING_c_str(analysis_data), handle);
STRING_delete(analysis_data);
}
}
}
void report_network_usage(const MEM_ANALYSIS_INFO* iot_mem_info)
void report_network_usage(REPORT_HANDLE handle, const MEM_ANALYSIS_INFO* iot_mem_info)
{
char date_time[DATE_TIME_LEN];
get_report_date(date_time, DATE_TIME_LEN);
STRING_HANDLE network_data = STRING_construct_sprintf(NETWORK_ANALYSIS_JSON_FMT, date_time, get_operation_type(iot_mem_info->operation_type), get_feature_type(iot_mem_info->feature_type), OS_NAME, iot_mem_info->iothub_version,
get_protocol_name(iot_mem_info->iothub_protocol), iot_mem_info->msg_sent, gbnetwork_getBytesSent(), (uint32_t)gbnetwork_getNumSends(), gbnetwork_getBytesRecv(), (uint32_t)gbnetwork_getNumRecv());
if (network_data == NULL)
if (handle != NULL)
{
(void)printf("ERROR: Failed to allocate networking json\r\n");
}
else
{
(void)printf("%s\r\n", STRING_c_str(network_data));
ThreadAPI_Sleep(10);
upload_to_azure(STRING_c_str(network_data));
STRING_delete(network_data);
}
char date_time[DATE_TIME_LEN];
get_report_date(date_time, DATE_TIME_LEN);
STRING_HANDLE network_data = STRING_construct_sprintf(NETWORK_ANALYSIS_JSON_FMT, date_time, get_operation_type(iot_mem_info->operation_type), get_feature_type(iot_mem_info->feature_type), OS_NAME, iot_mem_info->iothub_version,
get_protocol_name(iot_mem_info->iothub_protocol), iot_mem_info->msg_sent, gbnetwork_getBytesSent(), (uint32_t)gbnetwork_getNumSends(), gbnetwork_getBytesRecv(), (uint32_t)gbnetwork_getNumRecv());
if (network_data == NULL)
{
(void)printf("ERROR: Failed to allocate networking json\r\n");
}
else
{
(void)printf("%s\r\n", STRING_c_str(network_data));
ThreadAPI_Sleep(10);
upload_to_azure(STRING_c_str(network_data));
STRING_delete(network_data);
}
}
}
bool report_write(REPORT_HANDLE handle)

Просмотреть файл

@ -93,9 +93,9 @@ typedef struct REPORT_INFO_TAG* REPORT_HANDLE;
extern REPORT_HANDLE report_initialize(REPORTER_TYPE type);
extern void report_deinitialize(REPORT_HANDLE handle);
extern void report_memory_usage(const MEM_ANALYSIS_INFO* iot_mem_info);
extern void report_memory_usage(REPORT_HANDLE handle, const MEM_ANALYSIS_INFO* iot_mem_info);
extern void report_binary_sizes(REPORT_HANDLE handle, const BINARY_INFO* bin_info);
extern void report_network_usage(const MEM_ANALYSIS_INFO* iot_mem_info);
extern void report_network_usage(REPORT_HANDLE handle, const MEM_ANALYSIS_INFO* iot_mem_info);
extern bool report_write(REPORT_HANDLE handle);

Просмотреть файл

@ -7,10 +7,10 @@ function(add_memory_directory whatIsBuilding)
endfunction()
#add_memory_directory(device_method_mem)
add_analytic_directory(c2d_memory "heap_analysis")
#add_analytic_directory(c2d_memory "heap_analysis")
add_analytic_directory(telemetry_memory "heap_analysis")
add_analytic_directory(telemetry_net_info "network_info")
#add_analytic_directory(telemetry_net_info "network_info")
if (${use_prov_client})
add_analytic_directory(prov_net_info "network_info")
add_analytic_directory(provisioning_mem "prov_mem")
#add_analytic_directory(prov_net_info "network_info")
#add_analytic_directory(provisioning_mem "prov_mem")
endif()

Просмотреть файл

@ -182,7 +182,7 @@ int initiate_lower_level_operation(const CONNECTION_INFO* conn_info, PROTOCOL_TY
IoTHubClient_LL_Destroy(iothub_client);
report_memory_usage(&iot_mem_info);
report_memory_usage(NULL, &iot_mem_info);
}
}
return result;
@ -255,7 +255,7 @@ int initiate_upper_level_operation(const CONNECTION_INFO* conn_info, PROTOCOL_TY
IoTHubClient_Destroy(iothub_client);
report_memory_usage(&iot_mem_info);
report_memory_usage(NULL, &iot_mem_info);
}
}
return result;

Просмотреть файл

@ -217,6 +217,7 @@ static int construct_dev_conn_string(MEM_ANALYTIC_INFO* mem_info, CONNECTION_INF
static int parse_command_line(int argc, char* argv[], MEM_ANALYTIC_INFO* mem_info, CONNECTION_INFO* conn_info)
{
// -c "[connection_string]" -d [device_name] -k [device_key]
int result = 0;
ARGUEMENT_TYPE argument_type = ARGUEMENT_TYPE_UNKNOWN;
@ -268,30 +269,46 @@ static int parse_command_line(int argc, char* argv[], MEM_ANALYTIC_INFO* mem_inf
if (mem_info->device_info.deviceId == NULL && conn_info->scope_id == NULL)
{
#ifdef USE_HTTP
result = create_device(mem_info);
#else
result = __LINE__;
#endif
}
return result;
}
static void send_heap_info(CONNECTION_INFO* conn_info)
static void send_heap_info(CONNECTION_INFO* conn_info, REPORT_HANDLE report_handle)
{
// AMQP Sending
initiate_lower_level_operation(conn_info, PROTOCOL_AMQP, MESSAGES_TO_USE, USE_MSG_BYTE_ARRAY);
initiate_lower_level_operation(conn_info, PROTOCOL_AMQP_WS, MESSAGES_TO_USE, USE_MSG_BYTE_ARRAY);
#ifdef USE_AMQP
initiate_lower_level_operation(conn_info, report_handle, PROTOCOL_AMQP, MESSAGES_TO_USE, USE_MSG_BYTE_ARRAY);
initiate_lower_level_operation(conn_info, report_handle, PROTOCOL_AMQP_WS, MESSAGES_TO_USE, USE_MSG_BYTE_ARRAY);
#endif
// HTTP Sending
initiate_lower_level_operation(conn_info, PROTOCOL_HTTP, MESSAGES_TO_USE, USE_MSG_BYTE_ARRAY);
#ifdef USE_HTTP
initiate_lower_level_operation(conn_info, report_handle, PROTOCOL_HTTP, MESSAGES_TO_USE, USE_MSG_BYTE_ARRAY);
// MQTT Sending
initiate_lower_level_operation(conn_info, PROTOCOL_MQTT, MESSAGES_TO_USE, USE_MSG_BYTE_ARRAY);
initiate_lower_level_operation(conn_info, PROTOCOL_MQTT_WS, MESSAGES_TO_USE, USE_MSG_BYTE_ARRAY);
#endif
#ifdef USE_MQTT
initiate_lower_level_operation(conn_info, report_handle, PROTOCOL_MQTT, MESSAGES_TO_USE, USE_MSG_BYTE_ARRAY);
initiate_lower_level_operation(conn_info, report_handle, PROTOCOL_MQTT_WS, MESSAGES_TO_USE, USE_MSG_BYTE_ARRAY);
#endif
// AMQP Sending
initiate_upper_level_operation(conn_info, PROTOCOL_AMQP, MESSAGES_TO_USE, USE_MSG_BYTE_ARRAY);
initiate_upper_level_operation(conn_info, PROTOCOL_AMQP_WS, MESSAGES_TO_USE, USE_MSG_BYTE_ARRAY);
#ifdef USE_AMQP
initiate_upper_level_operation(conn_info, report_handle, PROTOCOL_AMQP, MESSAGES_TO_USE, USE_MSG_BYTE_ARRAY);
initiate_upper_level_operation(conn_info, report_handle, PROTOCOL_AMQP_WS, MESSAGES_TO_USE, USE_MSG_BYTE_ARRAY);
#endif
// HTTP Sending
initiate_upper_level_operation(conn_info, PROTOCOL_HTTP, MESSAGES_TO_USE, USE_MSG_BYTE_ARRAY);
#ifdef USE_HTTP
initiate_upper_level_operation(conn_info, report_handle, PROTOCOL_HTTP, MESSAGES_TO_USE, USE_MSG_BYTE_ARRAY);
#endif
// MQTT Sending
initiate_upper_level_operation(conn_info, PROTOCOL_MQTT, MESSAGES_TO_USE, USE_MSG_BYTE_ARRAY);
initiate_upper_level_operation(conn_info, PROTOCOL_MQTT_WS, MESSAGES_TO_USE, USE_MSG_BYTE_ARRAY);
#ifdef USE_MQTT
initiate_upper_level_operation(conn_info, report_handle, PROTOCOL_MQTT, MESSAGES_TO_USE, USE_MSG_BYTE_ARRAY);
initiate_upper_level_operation(conn_info, report_handle, PROTOCOL_MQTT_WS, MESSAGES_TO_USE, USE_MSG_BYTE_ARRAY);
#endif
}
int main(int argc, char* argv[])
@ -299,6 +316,8 @@ int main(int argc, char* argv[])
int result;
MEM_ANALYTIC_INFO mem_info;
CONNECTION_INFO conn_info;
REPORT_HANDLE report_handle;
memset(&mem_info, 0, sizeof(mem_info));
memset(&conn_info, 0, sizeof(conn_info));
@ -312,6 +331,12 @@ int main(int argc, char* argv[])
(void)printf("failed construct dev\r\n");
result = __LINE__;
}
else if ((report_handle = report_initialize(REPORTER_TYPE_JSON)) == NULL)
{
(void)printf("Failure creating report handle\r\n");
free(conn_info.device_conn_string);
result = __LINE__;
}
else if (initialize_sdk() != 0)
{
(void)printf("initializing SDK failed\r\n");
@ -320,18 +345,21 @@ int main(int argc, char* argv[])
}
else
{
send_heap_info(&conn_info);
send_heap_info(&conn_info, report_handle);
result = 0;
if (mem_info.create_device != 0)
{
#ifdef USE_HTTP
remove_device(&mem_info);
#endif
}
gballoc_deinit();
platform_deinit();
gbnetwork_deinit();
report_deinitialize(report_handle);
if (mem_info.create_device != 0)
{

Просмотреть файл

@ -23,8 +23,20 @@ ENDIF(WIN32)
add_definitions(-DUSE_TELEMETRY)
add_definitions(-DGB_MEASURE_MEMORY_FOR_THIS -DGB_DEBUG_ALLOC)
if (${use_mqtt})
add_definitions(-DUSE_MQTT)
endif()
if (${use_amqp})
add_definitions(-DUSE_AMQP)
endif()
if (${use_http})
add_definitions(-DUSE_HTTP)
endif()
if (${use_prov_client})
add_definitions(-DUSE_PROVISIONING_CLIENT)
endif()
include_directories(. .. ../..)
include_directories(${CMAKE_CURRENT_LIST_DIR} ${REPORTER_DIR} ${REPORTER_DIR}/deps/parson)
include_directories(${SDK_INCLUDE_DIRS})
add_executable(telemetry_memory ${telemetry_memory_c_files} ${telemetry_memory_h_files})
@ -47,17 +59,30 @@ link_directories(${IOTHUB_CLIENT_BIN_DIR})
target_link_libraries(telemetry_memory
iothub_client
iothub_client_mqtt_transport
iothub_client_mqtt_ws_transport
iothub_client_amqp_transport
iothub_client_amqp_ws_transport
iothub_client_http_transport
iothub_service_client
uamqp
umqtt
aziotsharedutil
)
if (${use_mqtt})
target_link_libraries(telemetry_memory
iothub_client_mqtt_transport
iothub_client_mqtt_ws_transport
umqtt
)
endif()
if (${use_amqp})
target_link_libraries(telemetry_memory
iothub_client_amqp_transport
iothub_client_amqp_ws_transport
uamqp
)
endif()
if (${use_http})
target_link_libraries(telemetry_memory
iothub_service_client
iothub_client_http_transport
)
endif()
if(WIN32)
target_link_libraries(telemetry_memory ws2_32 rpcrt4 ncrypt winhttp secur32 crypt32)
else()

Просмотреть файл

@ -44,21 +44,27 @@ static IOTHUB_CLIENT_TRANSPORT_PROVIDER initialize(MEM_ANALYSIS_INFO* iot_mem_in
iot_mem_info->iothub_protocol = protocol;
switch (protocol)
{
#ifdef USE_MQTT
case PROTOCOL_MQTT:
result = MQTT_Protocol;
break;
case PROTOCOL_MQTT_WS:
result = MQTT_WebSocket_Protocol;
break;
#endif
#ifdef USE_HTTP
case PROTOCOL_HTTP:
result = HTTP_Protocol;
break;
#endif
#ifdef USE_AMQP
case PROTOCOL_AMQP:
result = AMQP_Protocol;
break;
case PROTOCOL_AMQP_WS:
result = AMQP_Protocol_over_WebSocketsTls;
break;
#endif
default:
result = NULL;
break;
@ -88,7 +94,7 @@ static void iothub_connection_status(IOTHUB_CLIENT_CONNECTION_STATUS result, IOT
}
}
int initiate_lower_level_operation(const CONNECTION_INFO* conn_info, PROTOCOL_TYPE protocol, size_t num_msgs_to_send, bool use_byte_array_msg)
int initiate_lower_level_operation(const CONNECTION_INFO* conn_info, REPORT_HANDLE report_handle, PROTOCOL_TYPE protocol, size_t num_msgs_to_send, bool use_byte_array_msg)
{
int result;
IOTHUB_CLIENT_TRANSPORT_PROVIDER iothub_transport;
@ -201,14 +207,14 @@ int initiate_lower_level_operation(const CONNECTION_INFO* conn_info, PROTOCOL_TY
}
IoTHubClient_LL_Destroy(iothub_client);
report_memory_usage(&iot_mem_info);
report_memory_usage(report_handle, &iot_mem_info);
}
tickcounter_destroy(tick_counter_handle);
}
return result;
}
int initiate_upper_level_operation(const CONNECTION_INFO* conn_info, PROTOCOL_TYPE protocol, size_t num_msgs_to_send, bool use_byte_array_msg)
int initiate_upper_level_operation(const CONNECTION_INFO* conn_info, REPORT_HANDLE report_handle, PROTOCOL_TYPE protocol, size_t num_msgs_to_send, bool use_byte_array_msg)
{
int result;
IOTHUB_CLIENT_TRANSPORT_PROVIDER iothub_transport;
@ -324,7 +330,7 @@ int initiate_upper_level_operation(const CONNECTION_INFO* conn_info, PROTOCOL_TY
IoTHubClient_Destroy(iothub_client);
report_memory_usage(&iot_mem_info);
report_memory_usage(report_handle, &iot_mem_info);
}
tickcounter_destroy(tick_counter_handle);
}

Просмотреть файл

@ -15,8 +15,8 @@ extern "C" {
#include "mem_reporter.h"
extern int initiate_lower_level_operation(const CONNECTION_INFO* conn_info, PROTOCOL_TYPE protocol, size_t num_msgs_to_send, bool use_byte_array_msg);
extern int initiate_upper_level_operation(const CONNECTION_INFO* conn_info, PROTOCOL_TYPE protocol, size_t num_msgs_to_send, bool use_byte_array_msg);
extern int initiate_lower_level_operation(const CONNECTION_INFO* conn_info, REPORT_HANDLE report_handle, PROTOCOL_TYPE protocol, size_t num_msgs_to_send, bool use_byte_array_msg);
extern int initiate_upper_level_operation(const CONNECTION_INFO* conn_info, REPORT_HANDLE report_handle, PROTOCOL_TYPE protocol, size_t num_msgs_to_send, bool use_byte_array_msg);
#ifdef __cplusplus
}

Просмотреть файл

@ -208,7 +208,7 @@ int initiate_lower_level_operation(const CONNECTION_INFO* conn_info, PROTOCOL_TY
}
IoTHubClient_LL_Destroy(iothub_client);
report_network_usage(&iot_mem_info);
report_network_usage(NULL, &iot_mem_info);
}
tickcounter_destroy(tick_counter_handle);
}