使用说明:测试使用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. 使用T4模板技术

    1.右键->添加->新建项,选择“文本模板” 2.修改代码为: <#@ template debug="false" hostspecific="fal ...

  2. Hadoop实战-Flume之Sink Load-balancing(十七)

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

  3. PYTHON调用C接口(基于Ctypes)实现stein算法最大公约数的计算

    相关环境配置 mingw,选择相应的32位.64位的版本,主要用于编译动态链接库dll文件,可用vs替代,这里我选择轻量级的mingw windows64位地址:https://sourceforge ...

  4. Android LinearLayout线性布局

    LinearLayout是线性布局控件:要么横向排布,要么竖向排布 决定性属性:必须有的! android:orientation:vertical (垂直方向) .horizontal(水平方向) ...

  5. Carthage的使用

    1.安装Carthage https://github.com/Carthage/Carthage/releases 2.进入Cartfile文件所在的目录地址 cd 拖入文件Cartfile,把最后 ...

  6. 获取HDC的几种方法

    当需要在显示器上(当然包括打印机等设备上)绘图时,或者写文字的时候,需要取得设备的上下文句柄,即HDC,本文以下都称为HDC.那么,有哪些办法取得HDC呢? 1 BeginPain()和EndPain ...

  7. ubuntu tomcat 配置及使用细节

    1.改端口号(两个) vi server.xml 一个是http协议端口  <Connector port="8091" protocol="HTTP/1.1&qu ...

  8. POJ3415 Common Substrings —— 后缀数组 + 单调栈 公共子串个数

    题目链接:https://vjudge.net/problem/POJ-3415 Common Substrings Time Limit: 5000MS   Memory Limit: 65536K ...

  9. Appium——元素定位

    首先介绍两种定位元素的工具,appium自带的 Inspector 和 android SDK自带的 uiautomatorviewer 1.UIAutomator Viewer比较简单,在模拟器打开 ...

  10. L85

    Surgical Never Events Happen Nevertheless Surgeons call them "never events", because they ...