易截截图软件、单文件、免安装、纯绿色、仅160KB
热门标签: c c# c++ asp asp.net linux php jsp java vb Python Ruby mysql sql access Sqlite sqlserver delphi javascript Oracle ajax wap mssql html css flash flex dreamweaver xml
 最新文章 : linux

linux读写文件速度测试

一. 文件一次读入速度
linux下读文件这东西最后都是要通过系统调用sys_read(fd,buf,count)来实现的,所以如果要提高速度,就是最简单地调用sys_read的封装,比如直接用read()或fread()。下面是我在linux下的几个测试。
首先创建一个130M数据文件 dd if=/dev/zero of=data bs=1024k count=130
[dd if=/dev/zero of=data bs=1024k count=130 转换和拷贝文件,从输入if的源往of的目的地址拷贝,每个block1024k,一共拷贝130个。]
分别用fread,read和fgets一次读入全部大小文件所消耗时间对比,其中
size=130*1024*1024
char *buf=new char[size];
下面是测试结果(机器Intel(R) Pentium(R) 4 CPU 3.20GHz, Mem 1G):
1.fread(buf,size,1,fp)一次读入
real    0m0.187s
user    0m0.000s
sys     0m0.180s
2.read(fdin,(void *)buf,size)一次读入
real    0m0.187s
user    0m0.000s
sys     0m0.184s
3.多次fgets(buf,size,fp),每次1k
real    0m0.356s
user    0m0.136s
sys     0m0.220s
4.fgets(b ......

Linux C notes (BOOK UNIX)

Chapter 1: Thread
① thread functions
1. pthread_self();
2. thread existing
    you can get the value of rval_ptr just by  pthread_join(pthread_t tht, void ** rval_ptr)
    cancel a thread as the thread exits with PTHREAD_CANCELED in pthread_exit, this function        only send a signal but not wait until the thread really exits
        We can give a function to a thread with which the thread can invoke it when it exits. This
        pthread_clean_push
        These two functions must be in pairs in your function routines but not in the main                function. And one thing should be mentioned as : the routine should not be returned but
        pthread_detach(pthread_t tid)
4. Thread synchronization of thread
② thread. synchronics ......

Linux C notes (BOOK UNIX)

Chapter 1: Thread
① thread functions
1. pthread_self();
2. thread existing
    you can get the value of rval_ptr just by  pthread_join(pthread_t tht, void ** rval_ptr)
    cancel a thread as the thread exits with PTHREAD_CANCELED in pthread_exit, this function        only send a signal but not wait until the thread really exits
        We can give a function to a thread with which the thread can invoke it when it exits. This
        pthread_clean_push
        These two functions must be in pairs in your function routines but not in the main                function. And one thing should be mentioned as : the routine should not be returned but
        pthread_detach(pthread_t tid)
4. Thread synchronization of thread
② thread. synchronics ......

linux系统编程代码1

#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/sysmacros.h>
#include <time.h>
#include <unistd.h>
#define TIME_STRING_BUF 50
char * timestring(time_t t,char *buf)
 {
   struct tm *local;
local=localtime((&t);
strftime(buf,TIME_STRING_BUF,"%c",local);
return buf;
  }
 int statfile(const char * file)
{
 struct stat statbuf;
char timebuf[TIME_STRING_BUF];
if (lstat(file,%statbuf))
{
 fprintf(stderr,"could not lstat %s:%s\n",file,stderror(errno));
return 1;
}
 printf("filename : %s\n",file);
printf("on device : major %d/minor %d  inode number: %ld\n",major(statbuf.st_dev),minor(statbuf,st_dev),statbuf .st_ino)) )
printf("size     :%-10ld   type :  %07o     permissons  :%05o",statbuf,st_size,statbuf .st_mode&S_IFMT,st ......

Linux系统性能指标介绍

http://andrew913.javaeye.com/blog/431259
理解Linux调优参数
在我们介绍Linux系统的各种调优参数和性能监测工具之前,需要先讨论一些关于性能调优的参数。因为Linux是一个开源操作系统,所以又大量可用的性能监测工具。对这些工具的选择取决于你的个人喜好和对数据细节的要求。所有的性能监测工具都是按照同样的规则来工作的,所以无论你使用哪种监测工具都需要理解这些参数。下面列出了一些重要的参数,有效的理解它们是很有用处的。
(1)处理器参数
CPU utilization
这是一个很简单的参数,它直观的描述了每个CPU的利用率。在xSeries架构中,如果CPU的利用率长时间的超过80%,就可能是出现了处理器的瓶颈。
Runable processes
这个值描述了正在准备被执行的进程,在一个持续时间里这个值不应该超过物理CPU数量的10倍,否则CPU方面就可能存在瓶颈。
Blocked
描述了那些因为等待I/O操作结束而不能被执行的进程,Blocked可能指出你正面临I/O瓶颈。
User time
描述了处理用户进程的百分比,包括nice time。如果User time的值很高,说明系统性能用在处理实际的工作。
System time
描述了CPU花费在处理内核操作包括IRQ和软件中断上面的百分比。如果s ......

linux下的fastcopy

在拷贝数据的时候,如果遇到一堆小文件,即使总数据量很小,拷贝也会很费时,在win下,有一个软件叫fastcopy,可以实现快速拷贝,据说使用了一种叫内存映射的技术,那么在Linux下有没有呢?
我找了半天,原来LInux下根本不需要单独的软件,用现有的命令组合就OK了!
有高手在两个服务器间传数据,使用命令,实现了快速传送数据。
http://www.4bcj.com/post/2008/01/Fast-File-Copy—Linux!.aspx
All good ideas come out of necessity. We were cloning an instance of
Oracle Financials from one server to another. There are a LOT of files
under < 1k and the copy takes forever. Yesterday the copy was kicked
off using SCP - there was 39GBs to copy over a gigabit switch. This
should have been less than 10 minutes but actually took over 8 hours
because of all the small files. The copy failed and we needed to fix
the problem and copy it a lot faster (30 minutes) today.
After clearing up 10 GBs of log files, we were left with hundreds of
thousands of small files that were going to slow us down. We couldn&rsqu ......

让Linux系统防止syn攻击

虚拟主机服务商在运营过程中可能会受到黑客攻击,常见的攻击方式有SYN,DDOS等。通过更换IP,查找被攻击的站点可能避开攻击,但是中断服务的时间比较长。比较彻底的解决方法是添置硬件防火墙。不过,硬件防火墙价格比较昂贵。可以考虑利用Linux 系统本身提供的防火墙功能来防御。
抵御SYN SYN攻击是利用TCP/IP协议3次握手的原理,发送大量的建立连接的网络包,但不实际建立连接,最终导致被攻击服务器的网络队列被占满,无法被正常用户访问。
Linux内核提供了若干SYN相关的配置,用命令: sysctl -a | grep syn 看到:
net.ipv4.tcp_max_syn_backlog = 1024 net.ipv4.tcp_syncookies = 0
net.ipv4.tcp_synack_retries = 5 net.ipv4.tcp_syn_retries = 5
tcp_max_syn_backlog是SYN队列的长度,tcp_syncookies是一个开关,是否打开SYN Cookie 功能,该功能可以防止部分SYN攻击。tcp_synack_retries和tcp_syn_retries定义SYN 的重试次数。加大SYN队列长度可以容纳更多等待连接的网络连接数,打开SYN Cookie功能可以阻止部分 SYN攻击,降低重试次数也有一定效果。
调整上述设置的方法是:
增加SYN队列长度到2048:
sysctl -w net.ipv4.tcp_max_syn_backlog=2048
打开SYN ......
总记录数:5772; 总页数:962; 每页6 条; 首页 上一页 [590] [591] [592] [593] 594 [595] [596] [597] [598] [599]  下一页 尾页
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号