c++ Programming Glossary: sys
Copy a file in an sane, safe and efficient way http://stackoverflow.com/questions/10195343/copy-a-file-in-an-sane-safe-and-efficient-way blocksize like 1024 or 4096 higher values reduce number of system calls size_t BUFFER_SIZE 4096 char buf BUFSIZ size_t size.. blocksize like 1024 or 4096 higher values reduce number of system calls size_t BUFFER_SIZE 4096 char buf BUFSIZ size_t size.. WAY requires kernel 2.6.33 #include iostream #include sys sendfile.h sendfile #include fcntl.h open #include unistd.h..
Swapping two variable value without using 3rd variable http://stackoverflow.com/questions/1826159/swapping-two-variable-value-without-using-3rd-variable o swap The xor version takes real 0m2.068s user 0m2.048s sys 0m0.000s Where as the version with the temporary variable takes..
Get the IP address of the machine http://stackoverflow.com/questions/212528/get-the-ip-address-of-the-machine it show IPv6 addresses too. #include stdio.h #include sys types.h #include ifaddrs.h #include netinet in.h #include string.h..
C++ Timer function to provide time in nano seconds http://stackoverflow.com/questions/275004/c-timer-function-to-provide-time-in-nano-seconds For Linux and BSD you want to use clock_gettime . #include sys time.h int main timespec ts clock_gettime CLOCK_MONOTONIC ts..
C++ SMTP Example http://stackoverflow.com/questions/58210/c-smtp-example share improve this question #include iostream #include sys types.h #include sys socket.h #include netinet in.h #include.. question #include iostream #include sys types.h #include sys socket.h #include netinet in.h #include netdb.h #include stdio.h..
How to determine CPU and memory consumption from inside a process? http://stackoverflow.com/questions/63166/how-to-determine-cpu-and-memory-consumption-from-inside-a-process int numProcessors static HANDLE self void init SYSTEM_INFO sysInfo FILETIME ftime fsys fuser GetSystemInfo &sysInfo numProcessors.. HANDLE self void init SYSTEM_INFO sysInfo FILETIME ftime fsys fuser GetSystemInfo &sysInfo numProcessors sysInfo.dwNumberOfProcessors.. sysInfo FILETIME ftime fsys fuser GetSystemInfo &sysInfo numProcessors sysInfo.dwNumberOfProcessors GetSystemTimeAsFileTime..
how to achieve 4 FLOPs per cycle http://stackoverflow.com/questions/8389648/how-to-achieve-4-flops-per-cycle stdio.h #include stdlib.h #include math.h #include sys time.h double stoptime void struct timeval t gettimeofday t.. 3 addpd 's alternate with 3 mulpd 's well at least on my system and for my simple programme . My Core i5 750 Nahelem architecture.. the assembly code. Although difficult to admit but on my system cl O2 does a much better job at low level optimising operations..
Why is reading lines from stdin much slower in C++ than Python? http://stackoverflow.com/questions/9371238/why-is-reading-lines-from-stdin-much-slower-in-c-than-python Python Equivalent # usr bin env python import time import sys count 0 start time.time for line in sys.stdin count 1 delta_sec.. import time import sys count 0 start time.time for line in sys.stdin count 1 delta_sec int time.time start_time if delta_sec.. . readline_test_cpp 33.30 real 0.04 user 0.74 sys Saw 20000001 lines in 33 seconds. Crunch speed 606060 usr bin..
|