如何使用gprof对程序进行性能分析

news2024/11/29 12:54:08

如何使用gprof对程序进行性能分析


目录

1 gprof概述
2 gprof原理简述
3 gprof使用
  3.1 gprof使用简述
  3.2 gprof使用示例
4 小结


1 gprof概述

    gprof 是 一个 GNU 的程序性能分析工具,可以用于分析C\C++程序的执行性能。gprof工具可以统计出各个函数的调用次数、执行时间、函数调用关系,具体功能可以通过 man gprof进一步了解。通常该工具在大多数linux内核的发行版本中会在你安装C/C++编译器的同时默认安装上。


2 gprof原理简述

    通过在编译、链接的时候使用 -pg 选项,就能够控制gcc/g++ 编译器在程序的每个函数中插入插桩函数,从而跟踪目标函数的执行时间、调用关系(通过函数调用堆栈查找)、执行次数等信息,并将相关数据保存到 gmon.out 文件中。

    【注意】: 必须是编译链接的时候都要添加 -pg 参数。并且目标程序不能使用 strip 命令去除符号表,否则 gprof 工具无法正常处理 gmon.out 到 profile.txt文件。


3 gprof使用

3.1 gprof使用简述

a、 在编译、链接设置中开启 -pg 参数:

    使用cmake,在CMakeList.txt中添加

SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pg")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pg")
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pg")
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -pg")

    使用make,在Makefile中设置

CFLAGS += -pg
CPPFLAGS += -pg
LDFLAGS += -pg

b、 编译后正常运行程序

.testApp arg1 arg2

【注意】 运行程序后,要程序正常退出,才能正常生成 gmon.out 文件;在此步骤中程序是可以带命令行参数执行的。

c、 分析、收集数据

gprof testApp gmon.out > profile.txt

【注意】 在此步骤中,目标程序如果是带参的,此步骤不可以填入命令行参数。

d、 分析数据图形化

gprof2dot -e0 -n0 profile.txt > profile.dot
dot profile.dot -Tpng -o profile.png

【说明】 在此步骤中,需要通过 gprof2dot 和 dot工具将结果图形化,方便查看。

3.2 gprof使用示例

    上一小节简单讲述了如何 gprof 的使用,本小节会以 s_log_safe开源项目 为实例,介绍如何使用 gprof 工具 进行性能分析。

a、 clone s_log_safe项目源码

git clone https://github.com/smallerxuan/s_log_safe.git

cd s_log_safe

tree

clone完成后进入路径,能看到如下的目录结构:

在这里插入图片描述

b、 修改Makefile文件

gedit ./Makefile

用编辑器打开 Makefile文件,修改 FLAGS_BASE 关闭O2优化,添加 -pg 选项;给 LDFLAGS 追加 -pg;注释 strip 调用。

在这里插入图片描述

在这里插入图片描述
在这里插入图片描述

c、 调整测试用例并编译项目

gedit ./main.c

用编辑器打开 main.c 文件,对测试程序进行简单修改,不然测试程序不会自然结束。

#include <stdio.h>
#include "s_log_safe.h"

static int test_mark = 8;


void* thread_1_exec(void* arg)
{
    int* count =  (int*)arg;
    s_safe_tag("thread_1", S_LOG_SAFE_OPT_DEBUG);

    do {
        s_log_safe_a("%s %d","测试1",*count);
        usleep(5000);
    } while (*count -= 1);

    test_mark -= 1;
    return s_log_safe_null;
}

void* thread_2_exec(void* arg)
{
    int* count =  (int*)arg;
    s_safe_tag("thread_2", S_LOG_SAFE_OPT_DEBUG);

    do {
        s_log_safe_v("%s %d","测试2",*count);
        usleep(5000);
    } while (*count -= 1);

    test_mark -= 1;
    return s_log_safe_null;
}

void* thread_3_exec(void* arg)
{
    int* count =  (int*)arg;
    s_safe_tag("thread_3", S_LOG_SAFE_OPT_DEBUG);

    do {
        s_log_safe_e("%s %d","测试3",*count);
        usleep(5000);
    } while (*count -= 1);

    test_mark -= 1;
    return s_log_safe_null;
}

void* thread_4_exec(void* arg)
{
    int* count =  (int*)arg;
    s_safe_tag("thread_4", S_LOG_SAFE_OPT_DEBUG);

    do {
        s_log_safe_w("%s %d","测试4",*count);
        usleep(5000);
    } while (*count -= 1);

    test_mark -= 1;
    return s_log_safe_null;
}

void* thread_5_exec(void* arg)
{
    int* count =  (int*)arg;
    s_safe_tag("thread_5", S_LOG_SAFE_OPT_DEBUG);

    do {
        s_log_safe_t("%s %d","测试5",*count);
        usleep(5000);
    } while (*count -= 1);

    test_mark -= 1;
    return s_log_safe_null;
}

void* thread_6_exec(void* arg)
{
    int* count =  (int*)arg;
    s_safe_tag("thread_6", S_LOG_SAFE_OPT_DEBUG);

    do {
        s_log_safe_i("%s %d","测试6",*count);
        usleep(5000);
    } while (*count -= 1);

    test_mark -= 1;
    return s_log_safe_null;
}

void* thread_7_exec(void* arg)
{
    int* count =  (int*)arg;
    s_safe_tag("thread_7", S_LOG_SAFE_OPT_TRACE);

    do {
        s_log_safe_d("%s %d","测试7",*count);
        if((*count)%8 == 0) {
            s_safe_tag_log_level_limit_set(S_LOG_SAFE_OPT_DEBUG);
        } else {
            s_safe_tag_log_level_limit_set(S_LOG_SAFE_OPT_TRACE);
        }
        usleep(5000);
    } while (*count -= 1);

    test_mark -= 1;
    return s_log_safe_null;
}

void* thread_main_exec(void* arg)
{
    int count = 0;
    unsigned int log_safe_pool_cap = 0;
    unsigned int log_safe_pool_used = 0;
    s_safe_tag("main", S_LOG_SAFE_OPT_DEBUG);

    log_safe_pool_cap = s_log_safe_output_pool_cap_get();
    while(test_mark > 1) {
        log_safe_pool_used = s_log_safe_output_pool_used_get();
        s_log_safe_i("%s log_safe_pool_cap:%d log_safe_pool_used:%d count:%d","main", log_safe_pool_cap, log_safe_pool_used, count++);
        usleep(5000);
    }
    
    test_mark -= 1;
    return s_log_safe_null;
}

int main(void)
{
    int                  ret = 0;
    s_log_safe_thread_t* s_log_safe_thread_1_p;
    s_log_safe_thread_t* s_log_safe_thread_2_p;
    s_log_safe_thread_t* s_log_safe_thread_3_p;
    s_log_safe_thread_t* s_log_safe_thread_4_p;
    s_log_safe_thread_t* s_log_safe_thread_5_p;
    s_log_safe_thread_t* s_log_safe_thread_6_p;
    s_log_safe_thread_t* s_log_safe_thread_7_p;
    s_log_safe_thread_t* s_log_safe_thread_main_p;
    int                  count_1 = 77;
    int                  count_2 = 66;
    int                  count_3 = 55;
    int                  count_4 = 44;
    int                  count_5 = 33;
    int                  count_6 = 22;
    int                  count_7 = 11;

    ret = s_log_safe_init();
    if(ret != 0) {
        return 0;
    }
    s_log_safe_thread_7_p = s_log_safe_thread_create(thread_main_exec, (void*)s_log_safe_null, "", S_LOG_SAFE_THREAD_PRIORITY, 1024);
    s_log_safe_thread_1_p = s_log_safe_thread_create(thread_1_exec, (void*)&count_1, "", 10, 1024);
    s_log_safe_thread_2_p = s_log_safe_thread_create(thread_2_exec, (void*)&count_2, "", 10, 1024);
    s_log_safe_thread_3_p = s_log_safe_thread_create(thread_3_exec, (void*)&count_3, "", 12, 1024);
    s_log_safe_thread_4_p = s_log_safe_thread_create(thread_4_exec, (void*)&count_4, "", 12, 1024);
    s_log_safe_thread_5_p = s_log_safe_thread_create(thread_5_exec, (void*)&count_5, "", 11, 1024);
    s_log_safe_thread_6_p = s_log_safe_thread_create(thread_6_exec, (void*)&count_6, "", 11, 1024);
    s_log_safe_thread_7_p = s_log_safe_thread_create(thread_7_exec, (void*)&count_7, "", 10, 1024);

    while(test_mark != 0) {
        sleep(1);
    }
    return 0;
}

修改完成后运行make命令编译测试程序。

make

运行 make 命令后,会在 ./buld 路径生成目标测试程序。
在这里插入图片描述

d、 运测试程序

cd ./build/

./s_log_safe_test

切换到 ./build 路径后执行测试程序,通过 ls 会在路径下发现新生成了一个 gmon.out 文件。
在这里插入图片描述

e、 分析、收集数据

gprof s_log_safe_test gmon.out > profile.txt

通过该命令,可以在路径下看见导出的分析结果文件 profile.txt。在该文件中,详细的记录了 函数的执行时间、调用关系、执行次数等信息。但是还不是特别方便查看,毕竟看图会更直观。
在这里插入图片描述
profile.txt文件的内容如下:

Flat profile:

Each sample counts as 0.01 seconds.
 no time accumulated

  %   cumulative   self              self     total           
 time   seconds   seconds    calls  Ts/call  Ts/call  name    
  0.00      0.00     0.00     2048     0.00     0.00  s_log_safe_mutex_unlock
  0.00      0.00     0.00     2048     0.00     0.00  s_ring_buffer_unlock
  0.00      0.00     0.00     1294     0.00     0.00  s_log_safe_mutex_lock
  0.00      0.00     0.00     1294     0.00     0.00  s_ring_buffer_lock
  0.00      0.00     0.00      752     0.00     0.00  s_log_safe_mutex_try_lock
  0.00      0.00     0.00      752     0.00     0.00  s_log_strrchr
  0.00      0.00     0.00      751     0.00     0.00  s_ring_buffer_try_lock
  0.00      0.00     0.00      544     0.00     0.00  s_ring_buffer_could_read_num_get
  0.00      0.00     0.00      383     0.00     0.00  s_log_safe_out
  0.00      0.00     0.00      376     0.00     0.00  s_log_out_by_printf
  0.00      0.00     0.00      376     0.00     0.00  s_log_print
  0.00      0.00     0.00      376     0.00     0.00  s_log_safe_output
  0.00      0.00     0.00      376     0.00     0.00  s_ring_buffer_read_elements
  0.00      0.00     0.00      374     0.00     0.00  s_ring_buffer_write_elements
  0.00      0.00     0.00       78     0.00     0.00  s_log_safe_output_pool_used_get
  0.00      0.00     0.00        9     0.00     0.00  get_thread_policy
  0.00      0.00     0.00        9     0.00     0.00  s_log_safe_thread_create
  0.00      0.00     0.00        2     0.00     0.00  s_log_safe_mutex_create
  0.00      0.00     0.00        2     0.00     0.00  s_ring_buffer_lock_create
  0.00      0.00     0.00        1     0.00     0.00  s_log_safe_constructor
  0.00      0.00     0.00        1     0.00     0.00  s_log_safe_init
  0.00      0.00     0.00        1     0.00     0.00  s_log_safe_output_pool_cap_get
  0.00      0.00     0.00        1     0.00     0.00  s_ring_buffer_constructor
  0.00      0.00     0.00        1     0.00     0.00  s_ring_buffer_element_pool_constructor_malloc

 %         the percentage of the total running time of the
time       program used by this function.

cumulative a running sum of the number of seconds accounted
 seconds   for by this function and those listed above it.

 self      the number of seconds accounted for by this
seconds    function alone.  This is the major sort for this
           listing.

calls      the number of times this function was invoked, if
           this function is profiled, else blank.

 self      the average number of milliseconds spent in this
ms/call    function per call, if this function is profiled,
	   else blank.

 total     the average number of milliseconds spent in this
ms/call    function and its descendents per call, if this
	   function is profiled, else blank.

name       the name of the function.  This is the minor sort
           for this listing. The index shows the location of
	   the function in the gprof listing. If the index is
	   in parenthesis it shows where it would appear in
	   the gprof listing if it were to be printed.

Copyright (C) 2012-2015 Free Software Foundation, Inc.

Copying and distribution of this file, with or without modification,
are permitted in any medium without royalty provided the copyright
notice and this notice are preserved.

		     Call graph (explanation follows)


granularity: each sample hit covers 2 byte(s) no time propagated

index % time    self  children    called     name
                0.00    0.00    2048/2048        s_ring_buffer_unlock [2]
[1]      0.0    0.00    0.00    2048         s_log_safe_mutex_unlock [1]
-----------------------------------------------
                0.00    0.00       2/2048        s_ring_buffer_constructor [23]
                0.00    0.00     544/2048        s_ring_buffer_could_read_num_get [8]
                0.00    0.00     750/2048        s_ring_buffer_write_elements [14]
                0.00    0.00     752/2048        s_ring_buffer_read_elements [13]
[2]      0.0    0.00    0.00    2048         s_ring_buffer_unlock [2]
                0.00    0.00    2048/2048        s_log_safe_mutex_unlock [1]
-----------------------------------------------
                0.00    0.00    1294/1294        s_ring_buffer_lock [4]
[3]      0.0    0.00    0.00    1294         s_log_safe_mutex_lock [3]
-----------------------------------------------
                0.00    0.00     374/1294        s_ring_buffer_write_elements [14]
                0.00    0.00     376/1294        s_ring_buffer_read_elements [13]
                0.00    0.00     544/1294        s_ring_buffer_could_read_num_get [8]
[4]      0.0    0.00    0.00    1294         s_ring_buffer_lock [4]
                0.00    0.00    1294/1294        s_log_safe_mutex_lock [3]
-----------------------------------------------
                0.00    0.00     752/752         s_ring_buffer_try_lock [7]
[5]      0.0    0.00    0.00     752         s_log_safe_mutex_try_lock [5]
-----------------------------------------------
                0.00    0.00     752/752         s_log_safe_output [12]
[6]      0.0    0.00    0.00     752         s_log_strrchr [6]
-----------------------------------------------
                0.00    0.00     375/751         s_ring_buffer_write_elements [14]
                0.00    0.00     376/751         s_ring_buffer_read_elements [13]
[7]      0.0    0.00    0.00     751         s_ring_buffer_try_lock [7]
                0.00    0.00     752/752         s_log_safe_mutex_try_lock [5]
-----------------------------------------------
                0.00    0.00      78/544         s_log_safe_output_pool_used_get [15]
                0.00    0.00     466/544         s_log_safe_thread_exec_func [36]
[8]      0.0    0.00    0.00     544         s_ring_buffer_could_read_num_get [8]
                0.00    0.00     544/1294        s_ring_buffer_lock [4]
                0.00    0.00     544/2048        s_ring_buffer_unlock [2]
-----------------------------------------------
                0.00    0.00      11/383         thread_7_exec [50]
                0.00    0.00      22/383         thread_6_exec [49]
                0.00    0.00      33/383         thread_5_exec [48]
                0.00    0.00      43/383         thread_4_exec [47]
                0.00    0.00      55/383         thread_3_exec [46]
                0.00    0.00      66/383         thread_2_exec [45]
                0.00    0.00      76/383         thread_1_exec [44]
                0.00    0.00      77/383         thread_main_exec [51]
[9]      0.0    0.00    0.00     383         s_log_safe_out [9]
                0.00    0.00     374/374         s_ring_buffer_write_elements [14]
-----------------------------------------------
                0.00    0.00     376/376         s_log_print [11]
[10]     0.0    0.00    0.00     376         s_log_out_by_printf [10]
-----------------------------------------------
                0.00    0.00     376/376         s_log_safe_output [12]
[11]     0.0    0.00    0.00     376         s_log_print [11]
                0.00    0.00     376/376         s_log_out_by_printf [10]
-----------------------------------------------
                0.00    0.00     376/376         s_log_safe_thread_exec_func [36]
[12]     0.0    0.00    0.00     376         s_log_safe_output [12]
                0.00    0.00     752/752         s_log_strrchr [6]
                0.00    0.00     376/376         s_ring_buffer_read_elements [13]
                0.00    0.00     376/376         s_log_print [11]
-----------------------------------------------
                0.00    0.00     376/376         s_log_safe_output [12]
[13]     0.0    0.00    0.00     376         s_ring_buffer_read_elements [13]
                0.00    0.00     752/2048        s_ring_buffer_unlock [2]
                0.00    0.00     376/751         s_ring_buffer_try_lock [7]
                0.00    0.00     376/1294        s_ring_buffer_lock [4]
-----------------------------------------------
                0.00    0.00     374/374         s_log_safe_out [9]
[14]     0.0    0.00    0.00     374         s_ring_buffer_write_elements [14]
                0.00    0.00     750/2048        s_ring_buffer_unlock [2]
                0.00    0.00     375/751         s_ring_buffer_try_lock [7]
                0.00    0.00     374/1294        s_ring_buffer_lock [4]
-----------------------------------------------
                0.00    0.00      78/78          thread_main_exec [51]
[15]     0.0    0.00    0.00      78         s_log_safe_output_pool_used_get [15]
                0.00    0.00      78/544         s_ring_buffer_could_read_num_get [8]
-----------------------------------------------
                0.00    0.00       9/9           s_log_safe_thread_create [17]
[16]     0.0    0.00    0.00       9         get_thread_policy [16]
-----------------------------------------------
                0.00    0.00       1/9           s_log_safe_init [21]
                0.00    0.00       8/9           main [30]
[17]     0.0    0.00    0.00       9         s_log_safe_thread_create [17]
                0.00    0.00       9/9           get_thread_policy [16]
-----------------------------------------------
                0.00    0.00       2/2           s_ring_buffer_lock_create [19]
[18]     0.0    0.00    0.00       2         s_log_safe_mutex_create [18]
-----------------------------------------------
                0.00    0.00       2/2           s_ring_buffer_constructor [23]
[19]     0.0    0.00    0.00       2         s_ring_buffer_lock_create [19]
                0.00    0.00       2/2           s_log_safe_mutex_create [18]
-----------------------------------------------
                0.00    0.00       1/1           s_log_safe_init [21]
[20]     0.0    0.00    0.00       1         s_log_safe_constructor [20]
                0.00    0.00       1/1           s_ring_buffer_constructor [23]
-----------------------------------------------
                0.00    0.00       1/1           main [30]
[21]     0.0    0.00    0.00       1         s_log_safe_init [21]
                0.00    0.00       1/1           s_log_safe_constructor [20]
                0.00    0.00       1/9           s_log_safe_thread_create [17]
-----------------------------------------------
                0.00    0.00       1/1           thread_main_exec [51]
[22]     0.0    0.00    0.00       1         s_log_safe_output_pool_cap_get [22]
-----------------------------------------------
                0.00    0.00       1/1           s_log_safe_constructor [20]
[23]     0.0    0.00    0.00       1         s_ring_buffer_constructor [23]
                0.00    0.00       2/2           s_ring_buffer_lock_create [19]
                0.00    0.00       2/2048        s_ring_buffer_unlock [2]
                0.00    0.00       1/1           s_ring_buffer_element_pool_constructor_malloc [24]
-----------------------------------------------
                0.00    0.00       1/1           s_ring_buffer_constructor [23]
[24]     0.0    0.00    0.00       1         s_ring_buffer_element_pool_constructor_malloc [24]
-----------------------------------------------

 This table describes the call tree of the program, and was sorted by
 the total amount of time spent in each function and its children.

 Each entry in this table consists of several lines.  The line with the
 index number at the left hand margin lists the current function.
 The lines above it list the functions that called this function,
 and the lines below it list the functions this one called.
 This line lists:
     index	A unique number given to each element of the table.
		Index numbers are sorted numerically.
		The index number is printed next to every function name so
		it is easier to look up where the function is in the table.

     % time	This is the percentage of the `total' time that was spent
		in this function and its children.  Note that due to
		different viewpoints, functions excluded by options, etc,
		these numbers will NOT add up to 100%.

     self	This is the total amount of time spent in this function.

     children	This is the total amount of time propagated into this
		function by its children.

     called	This is the number of times the function was called.
		If the function called itself recursively, the number
		only includes non-recursive calls, and is followed by
		a `+' and the number of recursive calls.

     name	The name of the current function.  The index number is
		printed after it.  If the function is a member of a
		cycle, the cycle number is printed between the
		function's name and the index number.


 For the function's parents, the fields have the following meanings:

     self	This is the amount of time that was propagated directly
		from the function into this parent.

     children	This is the amount of time that was propagated from
		the function's children into this parent.

     called	This is the number of times this parent called the
		function `/' the total number of times the function
		was called.  Recursive calls to the function are not
		included in the number after the `/'.

     name	This is the name of the parent.  The parent's index
		number is printed after it.  If the parent is a
		member of a cycle, the cycle number is printed between
		the name and the index number.

 If the parents of the function cannot be determined, the word
 `<spontaneous>' is printed in the `name' field, and all the other
 fields are blank.

 For the function's children, the fields have the following meanings:

     self	This is the amount of time that was propagated directly
		from the child into the function.

     children	This is the amount of time that was propagated from the
		child's children to the function.

     called	This is the number of times the function called
		this child `/' the total number of times the child
		was called.  Recursive calls by the child are not
		listed in the number after the `/'.

     name	This is the name of the child.  The child's index
		number is printed after it.  If the child is a
		member of a cycle, the cycle number is printed
		between the name and the index number.

 If there are any cycles (circles) in the call graph, there is an
 entry for the cycle-as-a-whole.  This entry shows who called the
 cycle (as parents) and the members of the cycle (as children.)
 The `+' recursive calls entry shows the number of function calls that
 were internal to the cycle, and the calls entry for each member shows,
 for that member, how many times it was called from other members of
 the cycle.

Copyright (C) 2012-2015 Free Software Foundation, Inc.

Copying and distribution of this file, with or without modification,
are permitted in any medium without royalty provided the copyright
notice and this notice are preserved.

Index by function name

  [16] get_thread_policy (s_log_safe_platform.c) [1] s_log_safe_mutex_unlock [8] s_ring_buffer_could_read_num_get
  [10] s_log_out_by_printf     [9] s_log_safe_out         [24] s_ring_buffer_element_pool_constructor_malloc
  [11] s_log_print            [12] s_log_safe_output (s_log_safe.c) [4] s_ring_buffer_lock
  [20] s_log_safe_constructor (s_log_safe.c) [22] s_log_safe_output_pool_cap_get [19] s_ring_buffer_lock_create
  [21] s_log_safe_init        [15] s_log_safe_output_pool_used_get [13] s_ring_buffer_read_elements
  [18] s_log_safe_mutex_create [17] s_log_safe_thread_create [7] s_ring_buffer_try_lock
   [3] s_log_safe_mutex_lock   [6] s_log_strrchr           [2] s_ring_buffer_unlock
   [5] s_log_safe_mutex_try_lock [23] s_ring_buffer_constructor [14] s_ring_buffer_write_elements

f、 生成调用图

gprof2dot -e0 -n0 profile.txt > profile.dot
dot profile.dot -Tpng -o profile.png

通过 gprof2dot 和 dot 工具能够将 profile.txt 文件转换为 更直观的 图片。
在这里插入图片描述
在这里插入图片描述

如果没有安装 gprof2dot 和 dot 工具,可以通过以下命令进行安装:

sudo apt-get install graphviz

pip3 install gprof2dot

g、 查看调用图

通过上述操作,最终生成了 profile.png 文件,最终的调用图如下图所示:
在这里插入图片描述
从该图中,就比较直观的看到了调用流程和调用次数


4 小结

    上述的通过 gprof 和相关工具 对目标程序 进行 性能分析,是日常开发过程中常用的一种方式。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1851034.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

C语言小例程

题目&#xff1a;两个乒乓球队进行比赛&#xff0c;各出三人。甲队为a,b,c三人&#xff0c;乙队为x,y,z三人。已抽签决定比赛名单。有人向队员打听比赛的名单。a说他不和x比&#xff0c;c说他不和x,z比&#xff0c;请编程序找出三队赛手的名单。 #include <stdio.h> #in…

【职场人】职场进化记:我的“不惹人厌邀功精”之路

刚步入职场的我&#xff0c;就像一张白纸&#xff0c;什么都不懂&#xff0c;只知道埋头苦干。但渐渐地&#xff0c;我发现那些经常“冒泡”的同事似乎总能得到更多的关注和机会。我不禁想&#xff1a;“我是否也要成为那样一个‘邀功精’呢&#xff1f;” 不过&#xff0c;我…

BFS:解决最短路问题

文章目录 什么是最短路问题&#xff1f;1.迷宫中离入口最近的出口2.最小基因变化3.单词接龙4.为高尔夫比赛砍树总结 什么是最短路问题&#xff1f; 最短路问题是图论中的经典问题&#xff0c;旨在寻找图中两个节点之间的最短路径。常见的最短路算法有多种&#xff0c;这次我们…

MSPM0G3507——GPIO例程讲解1——input_capture

函数&#xff1a; 参数&#xff1a; 返回值&#xff1a; 主函数代码&#xff1a; #include "ti_msp_dl_config.h"extern volatile uint32_t interruptVectors[];int main(void) {SYSCFG_DL_init(); //把所有的LED灯和按键初始化了一…

idea导入文件里面的子模块maven未识别处理解决办法

1、File → Project Structure → 点击“Modules” → 点击“” → “Import Model” 2、可以看到很多子模块&#xff0c;选择子模块下的 pom.xml 文件导入一个一个点累死了&#xff0c;父目录下也没有pom文件 解决办法&#xff1a;找到子模块中有一个pom.xml文件&#xff0c;…

【CT】LeetCode手撕—42. 接雨水

目录 题目1- 思路2- 实现⭐42. 接雨水——题解思路 3- ACM实现 题目 原题连接&#xff1a;42. 接雨水 1- 思路 模式识别&#xff1a;求雨水的面积 ——> 不仅是只求一个比当前元素大的元素&#xff0c;还要求面积 单调栈 应用场景&#xff0c;需要找到左边比当前元素大的…

钓鱼隐藏--文件后缀压缩文件捆绑文件

免责声明:本文仅做技术交流与学习... 目录 文件后缀-钓鱼伪装-RLO 压缩文件-自解压-释放执行 捆绑文件-打包加载-释放执行 文件后缀-钓鱼伪装-RLO 改后缀--伪装 w.exe wgpj.exe (要改的后缀反写)(jpg--->gpj) | (光标移到要改的后缀的前边)(w和g中间) …

Sequelize入门及简单的增删改查

前言 学习一下NodeJS怎么使用Sequelize怎么查询数据库数据 一、Sequelize是什么&#xff1f; Sequelize 是一个基于 promise 的 Node.js ORM, 二、搭建项目 1.安装过程 npm i -g sequelize-cli //全局安装sequelize-clinpm i sequelize mysql2 //安装sequelize和mysql2…

基于YOLOv5的交通标志检测的设计与实现

简介 在智能交通系统中,交通标志的准确检测与识别对提高道路安全和交通效率至关重要。为了实现这一目标,我们开发了一种基于YOLOv5目标检测模型的交通标志检测系统。本报告将详细介绍该系统的实际应用与实现,包括系统架构、功能实现、使用说明、检测示例、数据集获取与介绍…

通信系统网络架构_1.局域网网络架构

当今&#xff0c;通信网络从大的方面主要包括局域网、广域网、移动通信网等网络形式。不同的网络会采用不同的技术进行网络构建。以下针对不同的网络给出各自的网络架构以及所采用的技术。 1.概述 局域网&#xff0c;即计算机局部区域网络&#xff0c;是一种为单一机构所拥有的…

运维.云技术学习.基于应用服务网格的灰度发布(上:理论基础篇)

运维专题 基于应用服务网格的灰度发布&#xff08;上&#xff1a;理论基础篇&#xff09; - 文章信息 - Author: 李俊才 (jcLee95) Visit me at CSDN: https://jclee95.blog.csdn.netMy WebSite&#xff1a;http://thispage.tech/Email: 291148484163.com. Shenzhen ChinaAdd…

CVPR‘24 最佳学生论文,从灵感到成稿仅用一个月,源自业余创意!

北京时间6月20日凌晨&#xff0c;CVPR 2024正式公布了最佳论文和最佳学生论文等奖项。 其中&#xff0c;最佳论文有两篇&#xff0c;分别是BioCLIP和Mip-Splatting。 据Mip-Splatting论文的第一作者Zehao Yu的导师、图宾根大学教授Andreas Geiger透露&#xff0c;这篇论文从想法…

CompletableFuture 基本用法

一、 CompletableFuture简介 CompletableFuture 是 Java 8 引入的一个功能强大的类&#xff0c;用于异步编程和并发处理。它提供了丰富的 API 来处理异步任务的结果&#xff0c;支持函数式编程风格&#xff0c;并允许通过链式调用组合多个异步操作。 二、CompletableFuture中…

Rocky Linux archive下载地址

Index of /vault/rocky/https://dl.rockylinux.org/vault/rocky/

【人工智能】—XGBoost算法在构建互联网防火墙异常行为识别模型应用案例

摘要&#xff1a; 近年来&#xff0c;各地党委、政府加快推进新型工业化&#xff0c;部署实施制造强市战略&#xff0c;提出工业企业“智改数转”是推动全市工业经济稳增长的重要引擎&#xff0c;更是稳增长、促发展的重要抓手。今天博主就以互联网防火墙异常行为识别为例给大家…

【Streamlit学习笔记】Streamlit-ECharts箱型图添加均值和最值label

Streamlit-ECharts Streamlit-ECharts是一个Streamlit组件&#xff0c;用于在Python应用程序中展示ECharts图表。ECharts是一个由百度开发的JavaScript数据可视化库Apache ECharts 安装模块库 pip install streamlitpip install streamlit-echarts绘制箱型图展示 在基础箱型…

内容安全复习 7 - 对抗攻击与防御

文章目录 概述攻击对抗性攻击的目的攻击的损失函数如何攻击FGSM黑盒与白盒真实世界的攻击 防御被动防御主动防御 概述 动机 &#xff08;1&#xff09;不仅要在实验室中部署机器学习分类器&#xff0c;也要在现实世界中部署&#xff1b;实际应用 &#xff08;2&#xff09;分类…

从一到无穷大 #29 ByteGraph的计算,内存,存储三级分离方案是否可以通用化为多模数据库

本作品采用知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议进行许可。 本作品 (李兆龙 博文, 由 李兆龙 创作)&#xff0c;由 李兆龙 确认&#xff0c;转载请注明版权。 文章目录 引言ByteGraph现有架构阿里云Lindorm腾讯YottaDB多模型化修改点ByteGraph论文中的优化…

IOS开发学习日记(十七)

简单的第三方登录和分享功能 第三方登录系统 URL Scheme&#xff1a;App间的跳转及通信 App间跳转场景 登陆系统&#xff1a; 跨平台&#xff0c;跨App 标记用户&#xff0c;个性化的推送 使用第三方登录&#xff08;减少注册成本 / 无须维护敏感信息&#xff09; 微信 / Q…

068、PyCharm 关于Live Template模板

在 PyCharm 编辑器中&#xff0c;Live Templates 是一种功能强大的工具&#xff0c;可以帮助我们快速插入常用的代码片段或模板。 以下是在 PyCharm 中添加 Live Templates 的步骤&#xff1a; 添加 Live Templates 步骤&#xff1a; 打开 PyCharm 编辑器。 转到菜单栏中的 …