debug gadget
来源:互联网 发布:淘宝微信返现不同意 编辑:程序博客网 时间:2024/06/06 19:26
// Author: Daniel
// Date: Apr.18, 2008
//Interface:
// void get_start_time();
// void get_end_time();
// void time_print(module_name);
// void print_once(void);
// void write_to_file(char* file_name, void * buffer, size_t count);
//
////////////////////////////////////////////////////////
#include <sys/time.h>
#include <stdio.h>
static struct timeval start_time, end_time, used_time, total_used_time;
static unsigned int count = 0;
void get_start_time(void)
{
gettimeofday(&start_time, NULL);
}
void get_end_time(void)
{
gettimeofday(&end_time, NULL);
}
void time_print(char * str)
{
printf("%s",str);
printf("TIME(Start:%d.%06ds, ", start_time.tv_sec, start_time.tv_usec);
printf("End:%d.%06ds, ", end_time.tv_sec,end_time.tv_usec);
if(end_time.tv_usec >= start_time.tv_usec){
used_time.tv_sec = end_time.tv_sec - start_time.tv_sec;
used_time.tv_usec = end_time.tv_usec - start_time.tv_usec;
printf("Used:%d.%06ds, ", used_time.tv_sec, used_time.tv_usec);
}
else{
used_time.tv_sec = end_time.tv_sec - start_time.tv_sec - 1;
used_time.tv_usec = 999999 - (start_time.tv_usec - end_time.tv_usec);
printf("Used:%d.%06ds, ", used_time.tv_sec, used_time.tv_usec);
}
++count;
total_used_time.tv_sec += used_time.tv_sec;
total_used_time.tv_usec += used_time.tv_usec;
printf("Average:%d.%06ds)/r", total_used_time.tv_sec / count,
total_used_time.tv_usec / count);
fflush(stdout);
}
//---------
void print_once(void)
{
static int print_once_flag = 1;
if(1 == print_once_flag) { printf("xxx/n"); print_once_flag = 0; }
}
//---------
#include <fcntl.h>
// O_RDONLY, O_WRONLY, O_RDWR, O_CREAT, O_TRUNC, O_APPEND
void write_to_file(char* file_name, void * buffer, size_t count)
{
int file_id = 0, file_length = 0;
file_id = open(file_name, O_WRONLY | O_CREAT);
file_length = write(file_id, buffer, count);
close(file_id);
printf("(%d) bytes written to file:%s /n", file_length, file_name );
}
////////////////////////////////////////////////////////////////
// Date: Apr.18, 2008
//Interface:
// void get_start_time();
// void get_end_time();
// void time_print(module_name);
// void print_once(void);
// void write_to_file(char* file_name, void * buffer, size_t count);
//
////////////////////////////////////////////////////////
#include <sys/time.h>
#include <stdio.h>
static struct timeval start_time, end_time, used_time, total_used_time;
static unsigned int count = 0;
void get_start_time(void)
{
gettimeofday(&start_time, NULL);
}
void get_end_time(void)
{
gettimeofday(&end_time, NULL);
}
void time_print(char * str)
{
printf("%s",str);
printf("TIME(Start:%d.%06ds, ", start_time.tv_sec, start_time.tv_usec);
printf("End:%d.%06ds, ", end_time.tv_sec,end_time.tv_usec);
if(end_time.tv_usec >= start_time.tv_usec){
used_time.tv_sec = end_time.tv_sec - start_time.tv_sec;
used_time.tv_usec = end_time.tv_usec - start_time.tv_usec;
printf("Used:%d.%06ds, ", used_time.tv_sec, used_time.tv_usec);
}
else{
used_time.tv_sec = end_time.tv_sec - start_time.tv_sec - 1;
used_time.tv_usec = 999999 - (start_time.tv_usec - end_time.tv_usec);
printf("Used:%d.%06ds, ", used_time.tv_sec, used_time.tv_usec);
}
++count;
total_used_time.tv_sec += used_time.tv_sec;
total_used_time.tv_usec += used_time.tv_usec;
printf("Average:%d.%06ds)/r", total_used_time.tv_sec / count,
total_used_time.tv_usec / count);
fflush(stdout);
}
//---------
void print_once(void)
{
static int print_once_flag = 1;
if(1 == print_once_flag) { printf("xxx/n"); print_once_flag = 0; }
}
//---------
#include <fcntl.h>
// O_RDONLY, O_WRONLY, O_RDWR, O_CREAT, O_TRUNC, O_APPEND
void write_to_file(char* file_name, void * buffer, size_t count)
{
int file_id = 0, file_length = 0;
file_id = open(file_name, O_WRONLY | O_CREAT);
file_length = write(file_id, buffer, count);
close(file_id);
printf("(%d) bytes written to file:%s /n", file_length, file_name );
}
////////////////////////////////////////////////////////////////
- debug gadget
- Linux USB Gadget 实现我们自己的ADB(android debug bridge ),Linux下高级调试功能(一)
- Gadget Driver
- usb gadget
- gadget 驱动
- Windows Vista Countdown gadget
- Gadget汉化教程
- SideShow Gadget开发[1]
- SideShow Gadget开发[2]
- 测试 Google Gadget
- Android Adb Gadget Driver
- Windows Gadget 制作二
- Windows Gadget 制作(三)
- 什么是mashup/widget/gadget?
- 认识Windows Gadget!
- google gadget学习
- Windows Gadget 开发常见问题
- [USB] usb gadget
- a wireshark's capture filter
- 最近ASP.NET WAP开发的一些情况!
- CHLAN的由来和GWF的伟大
- [转]java(Web)中相对路径,绝对路径问题总结
- 爆笑:“80后”夫妻生活白描
- debug gadget
- 查看PC的各种参数
- MVC Web Project-eclipse下的struts2插件
- disk usage display
- 列出所有进程
- 转:最强之dos命令 - for
- ls, find and grep's parameters and xargs
- diff & patch
- ctags