Programming :: Which Is Faster In These Fread() Commands
May 5, 2010Which is faster:
fread(&buf, 1, 1024, fp);
or
fread(&buf, 1024, 1, fp);
[code]...
Which is faster:
fread(&buf, 1, 1024, fp);
or
fread(&buf, 1024, 1, fp);
[code]...
I know this may be just me being a little bias on OS's but... I quite honestly believe that "some" programs run faster on linux than on windows.
Open Office for example, It runs amazingly fast on my linux distro but runs horribly (laggy) on my Vista machine.
Firefox also appears to run faster on my linux machine than on my Vista machine.
There are several more examples but I could go on and on with this.
My point is, do programs run faster on linux than on windows? Or is it just me that is in denial?
I am not sure if comparing linux to Vista is a good comparison in terms of program speed or not...
Also it should be noted that the Vista machine "hardware" is "several" times faster than my linux machine's "hardware".
I am not trying to start a flame war or anything like that, I am just trying to make sure I haven't totally lost my mind.
file allids consists of 300,000 rows, each containing a 5-7 digit numeric id. file newids consists of 20,000 rows of id's. How do you explain the following timings? time: 0.07s:
Code:
diff <(sort allids) <(sort newids)
time: 1.6s:
[code].....
I'm writing an interpreter and it used simple association lists for mapping varaible names to their values. Here's the code:
Code:
#include "assoc_array.hpp"
#include <string.h>
using namespace LANG_NAMESPACE;
[code]....
I thought that I would replace it with a hash table to increase performance. Note that I decided to store linked lists in the buckets instead of the actual values, in case the hash function outputs the same index for multiple variable names:
Code:
#include "hash_table.hpp"
#include "assoc_array.hpp"
#include <string.h>
[code]....
It runs in about 0.333 seconds on my machine. Since I'm using git version control, I decided to bring back the old version that used association lists. To my amazement, it ran 3 times faster, completing in 0.116 seconds! Is my hash table implementaion really that bad, or is this a really poor benchmark (and real-world code actually will be faster using the hash table)?
How can i get full command as and when a partially finish typing in Linux Command prompt. or is there a way i can get the command from history of commands executed automatically when i type instead of opening history and looking for the command?
View 7 Replies View RelatedI've tried instralling the c and c++ compilers on my fedora 13 machine and none of them seem to work. For example. i have this extremely simple c program that i try to compile and nothing works.
Code:
#include "stdio.h"
printf("Hello World");
[Code]....
I've written a for loop with a counter i and I want to use the value of i within sed to edit certain lines of text within a fortran file.I want the the x=10 will be replaced by x =1(counter from the loop).. and so on.But from the following code my x = 10 is replacing by x = i.So
I am getting error.
With the command "tail -300 /var/log/apache2/access.log | less" i can look in the log for the 300 latest visitors from my logfile. and i wanted to ask if it's possiblle to get that command to run from a php file and if yes how ?? how i run system commands in php? i use debian if it matters.
View 1 Replies View RelatedI'm learning GTK , and would like to use Codeblocks, and/or KDEvelop, and compile my c files using that, but always get an error about gtk/gtk.h not found, but can't figure out how to add the commands... I normally type gcc -o Program1 main.c `pkg-config --libs --cflags gtk+-2.0` That's a lot to type every time to compile.. Isn't there an easier way, in KDevelop, Monodevelop, and/or Codeblocks to make this step quicker, by adding some sort of I-/usr/include commands, or something?? thanks in advance, =). I looked online for some results, but didn't come across anything handy..
View 1 Replies View Relatedwant to set more text files. They have "tab" differently (3, 4, 6 or 5 characters space).I have to use "sed" or "awk" sette them in the same tab (for example five space haracters).
View 14 Replies View RelatedI am executing a run command in a script after that i need to copy files into a directory which are the inputs for the run,on run a new shell is created and the remaining commands in the script does not execute,wot should i do to execute the remaining commands in the script??
View 2 Replies View RelatedI am trying to administer a small group of ubuntu desktops in my classroom. I can use ssh to perform administrative tasks one at a time on each machine, but I want to automate these tasks through a small number of scripts. I am having trouble with running root commands through a script.
On other distros, I think I would simply ssh into the root account, and run the script. But as an ubuntu user, I have only ever used sudo, and folks at ubuntuforums are understandably hesitant to recommend logging in as root. Instead I am seeing suggestions to disable the password requirement for each specific command I want to run, which does not seem like best practice.
Should I enable the root account, give it a password, and ssh to the root account to run the scripts? To be specific, the scripts will do things like install updates, install programs, add or delete users, configure the desktop, etc.
Anyone know how to execute SQLite db commands from C++?
View 1 Replies View RelatedFor example, in GDB we talk about breakpoints, watchpoints and core dumps etc. Similarly what are the 'must knows' in Valgrind?
P.S. I don't need any links to Valgrind manuals, I already have them.
Code:
find . -name *.txt
Code:
find . -name *.txt
Where are the other BASH commands/exe stored? If the commands are part of the exe of BASH than ls would not be in a path, correct?
View 11 Replies View Relatedi need to run a command from a shell script that requires me to answer "Yes" to 2 questions that the command asks before it kicks off. how do i do this? i thought it was something like this.. from inside the parent script:
sh test.sh << "EOF
Yes
Yes
[code]...
im pretty sure this is a remedial task for many of you but im having an issue with arrays from a shell script being accessed in an awk command. im pretty good with shell scripting but i am embarrassingly unfamiliar with awk. so here's the meat of the script...
Code:
I am trying to take an input file of ip addresses and corresponding netmasks and put it into a format to be loaded onto a juniper switch. the result should look something like this.. x.x.x.x/netmask using the cidr notation. no matter what subnet is provided though, /32 always gets appended to the end of the ip even when it should be /16, /24, etc... also, the cisco part works fine so that doesnt need any attention.
how to run a linux commands in shell programming using control structures.
View 1 Replies View RelatedIn below program I want to add (as part of the valid_cmds string) the pwd (print working directory), lo (logout), and cd (change directory) commands. However when I add those into original program ;
char *valid_cmds = " ls ps df pwd lo cd";
they are not working I have the cout message huh?
Original source code is below code...
I am working on the shell using c language. I just would like to ask when I run some command in the backgrounds, how can I allow interleave out? I want to the output like this:
shell> command1
shell> command2 &
shell> command3
[code]...
I ran a perl script in background with nohup and disown to make sure my script runs even after the parent process is terminated.
Method 1: nohup
> nohup perl run.pl &
[1] 2080
Method 2: disown
> perl run.pl &
[2] 2448
> disown
In either method, the script process doesn't seem to connect to init process, when I checked using pstree command. I thought, the disown or nohup command detaches the process from its parent and attaches it to grand grand parent init process. And it disables SIGHUP signal to my script process. But the pstree command didn't show me what I expected. It still shows my script process attached to my current terminal process. I just don't understand the concept behind these two commands (nohup and disown). Is there any way, I can see the list of processes that are run by nohup or disown command?
I've worked with iptables in shell, but now I need to write an iptables command with perl. here is my code that I've tried but it didn't work :
Code:
#!/usr/bin/perl
print "Content-type: text/html
[code]...
I'm a newbie in Linux . what are the necessary commands for software engineering ?
View 13 Replies View RelatedI am working on a daemon that I want to change some variables while its running. Is this possible?I want to implement a command line type interface for my daemon so I can send it commands that will change the current values of specific variables, and also be able tell the daemon to load/save a config file.The only thing I have found so far is passing arguments to a daemon, but that seems to be a one-time shot when your first starting it.
View 6 Replies View RelatedI was zsync-ing the latest Ubuntu 11.10 Alpha and thought I'd make a little GUI for it as a small project. The gui is set up, I just need to figure out how to run zsync with content from to variables, cto and cfrom. I tried the following code:
[Code]....
I'm writing output of top command to a file However since top does not provide time I would like to append the 'date' command and then write all this to a file.
so something like top -d 1 -b; echo 'date' >>file
I have a command which on the command line needs to look like this
rlam -if3 '!pvalue -H image1.jpg' > image2.jpg
Nevermind what rlam or pvalue do ... they are part of a program package I am using. The above command works on the command line, and also when written verbatim in a bash shell script.
My problem is: in the script I wish to replace image1.jpg with the content of a variable, e.g.
IM1=image1.jpg
How to I get the script to insert the value of $IM into the command when the pvalue part of it needs to be quoted?
I need to write a windows batch file to run unix commands by logging onto a telnet unix server. For example , I might want the batch file to log onto the unix sever, run the ls command, collect the output in a file and ftp it back to my windows desktop
View 8 Replies View RelatedI am new to linux and would like to allow a user to use SUDO to change password and also delete/add members to a group without signing in as root or using SUDO. I think you do this in visudo but I dont know the commands to do this.
View 4 Replies View Related