使用说明:测试使用libphenom库的字符串追加函数,效率是strcat的60多倍。所以在进行大量的字符串累加的时候可以考虑使用libphenom库

 依赖库:

ck-0.4..tar.gz
cmake-3.1..tar.gz
libtap-1.12..tar.bz2
libphenom.tar.gz

安装步骤:

tar zxf ck-0.4..tar.gz
./configure
make
make install cp /usr/local/lib/pkgconfig/ck.pc /usr/lib64/pkgconfig/ vim /etc/ld.so.conf
/usr/local/lib/ tar zxf libphenom.tar.gz
./autogen.sh
./configure
make
make check
sudo make install tar zxf cmake-3.1..tar.gz
./configure
make
make install tar jxf libtap-1.12..tar.bz2
mkdir build
cd build
cmake ..
make
make check
make install

头文件:

#include <phenom/sysutil.h>
#include <phenom/string.h>
#include <phenom/stream.h>

编译选项 -lphenom -ltap:

例如:gcc libphenommain.c libphenomtest.c -lphenom -ltap

测试代码:

使用libphenommain.c和libphenomtest.c两个源码文件说明使用方法

libphenommain.c源码:

#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <phenom/sysutil.h>
#include <phenom/string.h>
#include <phenom/stream.h> ph_memtype_def_t mt_def = { "test", "misc", , };
ph_memtype_t mt_misc = ; int main ()
{
int bufsize = ; //初始化libphenom
ph_library_init();
mt_misc = ph_memtype_register (&mt_def); ph_string_t *text;
text = ph_string_make_empty (mt_misc, ); //追加字符串
test (text);
printf ("text content:%s\n", text->buf);
printf ("text len:%d\n", text->len); //释放
ph_string_delref(text);  return ;
}

libphenomtest.c源码:

#include <stdio.h>
#include <stdlib.h>
#include <phenom/sysutil.h>
#include <phenom/string.h>
#include <phenom/stream.h> extern ph_memtype_def_t mt_def;
extern ph_memtype_t mt_misc; int test (ph_string_t *text)
{
//字符串追加测试
int bufsize = 0;
char *buf = "hahah";

//ph_string_append_cstr(text, buf);
//注意这里使用的是ph_string_append_buf()这个函数,因为ph_string_append_cstr()这个函数
//遇到\0的话就会中断,使有\0的字符串追加不完整
bufsize = strlen(buf);
ph_string_append_buf (text, buf, bufsize);
char *buf2 = "hahah2";
//ph_string_append_cstr(text, buf2);
bufsize = strlen(buf2);
ph_string_append_buf (text, buf2, bufsize);
return 0;
}

说明:如果其他.c文件调用libphenom只要在主函数中初始化就可以,使用时在.c文件中加入

extern ph_memtype_def_t mt_def;
extern ph_memtype_t mt_misc;

编译链接:

gcc libphenommain.c libphenomtest.c -lphenom -ltap

 

linux下libphenom的测试代码的更多相关文章

  1. 怎样在Windows和Linux下写相同的代码

    目前,Linux在国内受到了越来越多的业内人士和用户的青睐.相信在不久的将来,在国内为Linux开发 的应用软件将会有很大的增加(这不,金山正在招兵买马移植WPS呢).由于未来将会是Windows和L ...

  2. RedHat Linux 下安装、测试摄像头

    RedHat Linux 下安装.测试摄像头(全文见附件)     随着视频电话的迅速发展我相信大家一定有过在Windows 下安装摄像头的经历,然而大多数 都不支持Linux .我现以罗技摄像头为例 ...

  3. Linux下18b20温度传感器驱动代码及测试实例

    驱动代码: #include <linux/module.h> #include <linux/fs.h> #include <linux/kernel.h> #i ...

  4. linux 下网站压力测试工具webbench

    一直在用webbench ,这个linux下的网站压力测试工具.整理下. 笔记本装的ubuntu,其他linux系统也差不多. webbench 需要先安装 ctags,一个vim的阅读插件,可以直接 ...

  5. 介绍linux下Source Insight强大代码编辑器sublime_text_3

    背景 1 一. 运行环境 1 二.安装环境配置 1 三.创建快捷方式 1 四.配置全局环境 2 五.操作界面 3 背景 在windows操作系统系统下,文本代码编辑器众多,各路英雄豪杰争相写了许多强大 ...

  6. Linux下的压力测试工具:ab、http_load、webbench、siege

    一.ab 1.1 介绍 ab是apache自带的一款功能强大的测试工具.      安装了apache一般就自带了. 1.2 下载 同apache. 1.3 安装 同apache. 1.4 安装结果 ...

  7. mocha框架下,异步测试代码错误造成的问题----用例超时错误

    今天用抹茶(mocha)做个测试,发现有一个测试项目总是超时: describe("DbFactory functions",function(){ it("query ...

  8. linux下使用indent整理代码(代码格式化)【转】

    转自:https://blog.csdn.net/jiangjingui2011/article/details/7197069 常用的设置: indent -npro -kr -i8 -ts8 -s ...

  9. Linux下简易蜂鸣器驱动代码及测试实例

    驱动代码: #include <linux/module.h> #include <linux/kernel.h> #include <linux/init.h> ...

随机推荐

  1. 14、AppWidget及Launcher RemoteViews

    一.Launcher的简单研究 1 什么是Launcher Android系统启动后加载的第一个程序 . 这个程序是其他应用程序的入口 . Launcher构成: HomeScreen : (Work ...

  2. JAVA数据类型(转)

     java中数据的基本类型分为: 基本数据类型和引用数据类型,对此不多介绍:   接下来讨论一下java中数据类型存储在哪     基本数据类型存储在哪,取决于基本类型在哪声明:          1 ...

  3. c++标准库比较

    1 GNU standard c++ library debian发行版中使用的c++标准库是GNU standard c++标准库. 2 Boost debian发行版中也是用了boost库,但是不 ...

  4. static 不被实例调用

    static - JavaScript | MDN https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/ ...

  5. Hadoop实战-Flume之Source regex_extractor(十二)

    a1.sources = r1 a1.sinks = k1 a1.channels = c1 # Describe/configure the source a1.sources.r1.type = ...

  6. 我的Java开发学习之旅------>Java String对象作为参数传递的问题解惑

    又是一道面试题,来测试你的Java基础是否牢固. 题目:以下代码的运行结果是? public class TestValue { public static void test(String str) ...

  7. ABap-小技巧

    if FIELD cn '0123456789'. *&如果字符串包含‘数字’    STOP.  endif. 同理到字母‘ABCDEFG*’ 'abcdefg*' '/' '\' 等其它字 ...

  8. python仪表盘

    1.在这里可以看到pyecharts中有定义好的各种图标类. 复制上面代码,会出现“ModuleNotFoundError: No module named 'pyecharts'”. pip ins ...

  9. MySQL——sql语句的执行顺序

    #核心知识点: 书写顺序:where——>group by——>having——>order by——>limit 许多时候在书写一些复杂的sql语句的时候,尤其是在渐进式推导 ...

  10. 在maven 中部署SSM项目找不 Spring ContextLoaderListener 的解决办法

    1.项目使用技术:maven的项目使用了Spring MVC+Spring +Mybatis+Tomcat搭建一个项目. 2.报错信息: Error configuring application l ...