#对v语言二进制文件提取符号
nm -D ./v_sort > vlan.h
#对rust语言二进制文件提取符号
nm -D rust-sort/target/release/rust-sort >rslan.h
./duckdb130
D select count(*) from read_csv('vlan.h'); -- v语言符号计数
┌──────────────┐
│ count_star() │
│ int64 │
├──────────────┤
│ 78 │
└──────────────┘
D select count(*) from read_csv('rslan.h'); -- rust语言符号计数
┌──────────────┐
│ count_star() │
│ int64 │
├──────────────┤
│ 57 │
└──────────────┘
D select count(*) from (from read_csv('rslan.h') intersect from read_csv('vlan.h')); -- v语言和rust语言共有符号计数
┌──────────────┐
│ count_star() │
│ int64 │
├──────────────┤
│ 22 │
└──────────────┘
D .system bash
#对c语言二进制文件提取符号
nm -D ./c_sort > clan.h
#对zig语言二进制文件提取符号,不能提取出符号
nm -D ./main > zlan.h
nm: ./main: no symbols
exit
D select count(*) from read_csv('clan.h');
┌──────────────┐
│ count_star() │
│ int64 │
├──────────────┤
│ 16 │
└──────────────┘
#对使用文件内存映射的c语言二进制文件提取符号
D .system nm -D ./zcsort > zclan.h
D select count(*) from read_csv('zclan.h');
┌──────────────┐
│ count_star() │
│ int64 │
├──────────────┤
│ 16 │
└──────────────┘
D select count(*) from (from read_csv('clan.h') intersect from read_csv('zclan.h'));
┌──────────────┐
│ count_star() │
│ int64 │
├──────────────┤
│ 8 │
└──────────────┘
D select count(*) from (from read_csv('rslan.h') intersect from read_csv('zclan.h'));
┌──────────────┐
│ count_star() │
│ int64 │
├──────────────┤
│ 6 │
└──────────────┘
#可见rust和使用文件内存映射的c语言都调用了munmap
D from (from read_csv('rslan.h') intersect from read_csv('zclan.h'));
┌─────────────────────────────────────────────────┐
│ U _Unwind_Backtrace@GCC_3.3 │
│ varchar │
├─────────────────────────────────────────────────┤
│ U exit@GLIBC_2.2.5 │
│ U close@GLIBC_2.2.5 │
│ U calloc@GLIBC_2.2.5 │
│ U munmap@GLIBC_2.2.5 │
│ U __libc_start_main@GLIBC_2.34 │
│ U free@GLIBC_2.2.5 │
└─────────────────────────────────────────────────┘
-- 使用文件内存映射的c语言和普通c语言都调用了qsort
D from (from read_csv('clan.h') intersect from read_csv('zclan.h'));
┌─────────────────────────────────────────────────┐
│ w _ITM_deregisterTMCloneTable │
│ varchar │
├─────────────────────────────────────────────────┤
│ U fstat@GLIBC_2.33 │
│ U open@GLIBC_2.2.5 │
│ U close@GLIBC_2.2.5 │
│ U strcmp@GLIBC_2.2.5 │
│ U __libc_start_main@GLIBC_2.34 │
│ U free@GLIBC_2.2.5 │
│ U fprintf@GLIBC_2.2.5 │
│ U qsort@GLIBC_2.2.5 │
└─────────────────────────────────────────────────┘
-- v语言和rust语言共有符号计数
D from (from read_csv('rslan.h') intersect from read_csv('vlan.h'));
┌─────────────────────────────────────────────────────┐
│ U _Unwind_Backtrace@GCC_3.3 │
│ varchar │
├─────────────────────────────────────────────────────┤
│ U read@GLIBC_2.2.5 │
│ U memmove@GLIBC_2.2.5 │
│ U close@GLIBC_2.2.5 │
│ U pthread_getattr_np@GLIBC_2.32 │
│ U signal@GLIBC_2.2.5 │
│ U __libc_start_main@GLIBC_2.34 │
│ U free@GLIBC_2.2.5 │
│ U memcpy@GLIBC_2.14 │
│ U memset@GLIBC_2.2.5 │
│ U pthread_attr_getstack@GLIBC_2.34 │
│ U abort@GLIBC_2.2.5 │
│ U sigaction@GLIBC_2.2.5 │
│ U fcntl@GLIBC_2.2.5 │
│ U mprotect@GLIBC_2.2.5 │
│ U getenv@GLIBC_2.2.5 │
│ U pthread_attr_destroy@GLIBC_2.2.5 │
│ U write@GLIBC_2.2.5 │
│ U pthread_self@GLIBC_2.2.5 │
│ U exit@GLIBC_2.2.5 │
│ U __errno_location@GLIBC_2.2.5 │
│ U memcmp@GLIBC_2.2.5 │
│ U strlen@GLIBC_2.2.5 │
├─────────────────────────────────────────────────────┤
│ 22 rows │
└─────────────────────────────────────────────────────┘
-- v和c语言都调用了qsort
D from (from read_csv('clan.h') intersect from read_csv('vlan.h'));
┌─────────────────────────────────────────────────┐
│ w _ITM_deregisterTMCloneTable │
│ varchar │
├─────────────────────────────────────────────────┤
│ U open@GLIBC_2.2.5 │
│ U close@GLIBC_2.2.5 │
│ U __libc_start_main@GLIBC_2.34 │
│ U free@GLIBC_2.2.5 │
│ w __gmon_start__ │
│ U read@GLIBC_2.2.5 │
│ U fprintf@GLIBC_2.2.5 │
│ U qsort@GLIBC_2.2.5 │
└─────────────────────────────────────────────────┘
知道了这些信息,对于不同语言的性能表现就会有比较准确的预计了。除了intersect还可以用except找出不同程序调用其他程序未调用的函数。
read_csv(‘文件名’ header=0)可以提示duckdb不把文件当作有标题行的。

被折叠的 条评论
为什么被折叠?



