Calculating time in LINUX in milliseconds and Seconds. We should include sys/time.h header file and the remaining sample code is
struct timeval start;
we wil be using gettimeofday system call whose syntax is
int gettimeofday(struct timeval *tv, struct timezone *tz); where
struct timeval
{
time_t tv_sec;···············/* seconds */
suseconds_t tv_usec;······/* microseconds */
};
/* To calculate time in seconds*/
gettimeofday(&start, NULL);
starttime = start.tv_sec + start.tv_usec/1000000;
/* To calculate time in milliseconds*/
gettimeofday(&start, NULL);
starttime = start.tv_sec*1000 + start.tv_usec/1000;
6.16.2008
6.14.2008
Using GOOGLE as proxy to hide IP-Adress
NOTE (UPDATED on FEBRUARY 30th 2009): This trick seems to be no more fool proof as sites like tracemyip tracks down your exact IP-Adress even by using the Google Translation Service.
We know that GOOGLE has changed the way we access the web. It has simply became the stepping stone for any body who want to know information about anything in this world .. offcourse of universe too. It had wide variety of web based applications namely search, maps, gmail, gears, adsense, adwords, analyzers, language translators and many in its arsenal.
Now we can use one of the services of GOOGLE as proxy so that we can access the web anonymously without revealing our ipadress, location of our ISP. You might be wondering how our location is revealed out? Let us try out a simple experiment. Just visit the site
http://www.ip-adress.com/
We can see that the site reveals my ISP ipadress as 59.164.98.133 and my ISP location in a google map as Bangalore. If we further check out the site we can find out that the site has ecen information about our browser version, plugins installed, our screen resolution and many other things got revealed.
So how does GOOGLE service can be used a proxy? Let us check out the language translation service provided by the GOOGLE. You can get the link to this service if you type www.google.com and we can see a link to language tools or just click this link.
http://www.google.co.in/language_tools?hl=en
Once you click you are into that page we can see a option named "Translate a Webpage" with options to translate from one language to other. Note we cant translate same language to the same one i.e. for example from English to English. If we try to do it we get a GOOGLE ERROR.
Not let us try to access the site http://www.ip-adress.com/ asking GOOGLE translation service to convert the site from from French to English. Since nothing French is there in that site is simply displayed in English.
Strange it displays my ISP ip-adress as 209.85.170.136 and its location as United States. If I check out the site further I found out that I am getting redirected via google server present at Mountain View, US which is acting as proxy to access the site http://www.ip-adress.com/.
So we can access the any site in this way without revealing our information much. Thats really cool trick to stay anonymous. But there is a problem by doing so as the images cannot seen properly by using this technique. But even if a site is bocked we can access its content in this way. I tried out this trick on one of the torrent sites that are blocked but I can still access its contents.
We know that GOOGLE has changed the way we access the web. It has simply became the stepping stone for any body who want to know information about anything in this world .. offcourse of universe too. It had wide variety of web based applications namely search, maps, gmail, gears, adsense, adwords, analyzers, language translators and many in its arsenal.
Now we can use one of the services of GOOGLE as proxy so that we can access the web anonymously without revealing our ipadress, location of our ISP. You might be wondering how our location is revealed out? Let us try out a simple experiment. Just visit the site
http://www.ip-adress.com/
We can see that the site reveals my ISP ipadress as 59.164.98.133 and my ISP location in a google map as Bangalore. If we further check out the site we can find out that the site has ecen information about our browser version, plugins installed, our screen resolution and many other things got revealed.
So how does GOOGLE service can be used a proxy? Let us check out the language translation service provided by the GOOGLE. You can get the link to this service if you type www.google.com and we can see a link to language tools or just click this link.
http://www.google.co.in/language_tools?hl=en
Once you click you are into that page we can see a option named "Translate a Webpage" with options to translate from one language to other. Note we cant translate same language to the same one i.e. for example from English to English. If we try to do it we get a GOOGLE ERROR.
Not let us try to access the site http://www.ip-adress.com/ asking GOOGLE translation service to convert the site from from French to English. Since nothing French is there in that site is simply displayed in English.
Strange it displays my ISP ip-adress as 209.85.170.136 and its location as United States. If I check out the site further I found out that I am getting redirected via google server present at Mountain View, US which is acting as proxy to access the site http://www.ip-adress.com/.
So we can access the any site in this way without revealing our information much. Thats really cool trick to stay anonymous. But there is a problem by doing so as the images cannot seen properly by using this technique. But even if a site is bocked we can access its content in this way. I tried out this trick on one of the torrent sites that are blocked but I can still access its contents.
5.28.2008
Converting mobilephone into webcam
Camera in a mobilephone is getting better day by day and reached upto 5MP with good clarity and cool features. Until now we have used mobile camera for just taking pictures and recording video's. But now we can even use it as a webcam for chatting online on any popular messenger service available.
Let us check out some of the cool softwares that converts a camera phone into a webcam.
Mobiola
It converts your phone into a webcam via Bluetooth or through USB cable.It consists of two parts - a PC application with virtual camera driver and Symbian sis application for smartphone.Features:
RIM Blackberry - Any Blackberry devices equipped with camera
Windows Mobile - Windows Mobile 5 and 6 devices equipped with camera including Smartphones
Nokia 6600, 6620, 7610, 6630, 6670, 6260,6680, 6681, 6682, 3230, N70,N90, 3250, 5500, E50, E51, E65, E70, E90, N71, N73, N76, N80, N81, N82, N91,N92, N93, N93i, N95, N96
Sony-Ericsson P1i, P990, M600, W950, W960, P800, P900, P910, P990, G700, G900
Motorola Z8, Z10
If you don't have a webcam, or want a more versatile solution to your current cam, then Mobiola WebCam is an essential download.
Limitations:
30 day Trial Period Limited to 5 minutes connection.
Actual Link: http://www.warelex.com/
WWigo
This is an alternative for Mobiola since it is free to use. It has got all most all the features supported by Mobiola.
Actual Link: http://www.motvik.com/
Let us check out some of the cool softwares that converts a camera phone into a webcam.
Mobiola
It converts your phone into a webcam via Bluetooth or through USB cable.It consists of two parts - a PC application with virtual camera driver and Symbian sis application for smartphone.Features:
- Transforms your mobile phone into high-quality PC webcam.
- Connects through USB or Bluetooth.
- Screen Capture functionality.
- Works with Skype, Yahoo, YouTube, MSN, AOL IM, ICQ and many others as standard USB webcam.
RIM Blackberry - Any Blackberry devices equipped with camera
Windows Mobile - Windows Mobile 5 and 6 devices equipped with camera including Smartphones
Nokia 6600, 6620, 7610, 6630, 6670, 6260,6680, 6681, 6682, 3230, N70,N90, 3250, 5500, E50, E51, E65, E70, E90, N71, N73, N76, N80, N81, N82, N91,N92, N93, N93i, N95, N96
Sony-Ericsson P1i, P990, M600, W950, W960, P800, P900, P910, P990, G700, G900
Motorola Z8, Z10
If you don't have a webcam, or want a more versatile solution to your current cam, then Mobiola WebCam is an essential download.
Limitations:
30 day Trial Period Limited to 5 minutes connection.
Actual Link: http://www.warelex.com/
WWigo
This is an alternative for Mobiola since it is free to use. It has got all most all the features supported by Mobiola.
Actual Link: http://www.motvik.com/
4.07.2008
TinTin E-Book collection
There are download links available below each and every Image of the TiTle book ... If any problem in seeing them please leave a comment .....
01. Tintin in the Land of the Soviets (1930)
02. Tintin in the Congo (1931)
03. Tintin in America (1932)
04. Cigars of the Pharaoh
05. The Blue Lotus (1936)
06. The Broken Ear
07. The Black Island (1938)
08. King Ottokar's Sceptre (1939)
09. The Crab with the Golden Claws (1941)
10. The Shooting Star (1942)
Checkout TinTin ebook collection part2 for the books from 11 to 20
Checkout TinTin ebook collection part3 for the remaining editions.
01. Tintin in the Land of the Soviets (1930)
02. Tintin in the Congo (1931)
03. Tintin in America (1932)
04. Cigars of the Pharaoh
05. The Blue Lotus (1936)
06. The Broken Ear
07. The Black Island (1938)
08. King Ottokar's Sceptre (1939)
09. The Crab with the Golden Claws (1941)
10. The Shooting Star (1942)
Checkout TinTin ebook collection part2 for the books from 11 to 20
Checkout TinTin ebook collection part3 for the remaining editions.
4.03.2008
Optimization levels in GCC
Compilers have become pretty smart as they can perform all sorts of code transformations — from simple inlining to sophisticated register analysis — that make compiled code run faster.
In most situations, faster is better than smaller, because disk space and memory are quite cheap for desktop users. However, for embedded systems small is often at least as important as fast because of a commonplace environment consisting of extreme memory constraints and no disk space, making code optimization a very important task.
Optimization is a complex process. For each high-level command in the source code there are usually many possible combination's of machine instructions that can be used to achieve the appropriate final result. The compiler must consider these possibilities and choose among them.
In general, different code must be generated for different processors, as they use incompatible assembly and machine languages. Each type of processor also has its own characteristics -- some CPU's provide a large number of registers for holding intermediate results of calculations, while others must store and fetch intermediate results from memory. Appropriate code must be generated in each case.
Furthermore, different amounts of time are needed for different instructions, depending on how they are ordered. GCC takes all these factors into account and tries to produce the fastest executable for a given system when compiling with optimization.
Turning optimization flags ON makes the compiler attempt to improve the performance and/or code size at the expense of compilation time and possibly the ability to debug the program.
NOTE: While the GCC optimizer does a good job of code optimization, it can sometimes result in larger or slower images (the opposite of what you may be after). It’s important to test your image to ensure that you’re getting what you expect. When you don’t get what you expect, changing the options you provide to the optimizer can usually remedy the situation.
Let us see various optimization levels provided by GCC
LEVEL 0: -O0 Optimization
At this optimization level GCC does not perform any optimization and compiles the source code in the most straightforward way possible. Each command in the source code is converted directly to the corresponding instructions in the executable file, without rearrangement. This is the best option to use when debugging with a source code debugger (such as the GNU Debugger, GDB). It is the default level of optimization if no optimization level option is specified. It can be specified as
NOTE: -O0 is actually -(Capital O)(Number 0). Similarly -O1 is -(Capital O)(Number 1).
LEVEL 1: -O1 Optimization (-O)
In the first level of optimization, the optimizer’s goal is to compile as quickly as possible and also to reduce the resulting code size and execution time. Compilation may take more time with -O1 (over -O0), but depending upon the source being compiled, this is usually not noticeable. Level 1 also has two sometimes conflicting goals. These goals are to reduce the size of the compiled code while increasing its performance. The set of optimizations provided in -O1 support these goals, in most cases.
The -O1 optimization is usually a safe level if you still desire to safely debug the resulting image. Check out the table given below for optimizations enabled at different levels.
NOTE: Any optimization can be enabled outside of any level simply by specifying its name with the -f prefix, for example, to enable the defer-pop optimization, we would simply define this as
We could also enable level 1 optimization and then disable any particular optimization using the -fno- prefix, like this:
This command would enable the first level of optimization and then specifically disable the defer-pop optimization.
LEVEL 2: -O2 Optimization
The second level of optimization provides even more optimizations (while including those in -O1, plus a large number of others). Only optimizations that do not require any speed-space tradeoffs are used, so the executable should not increase in size. The compiler will take longer to compile programs and require more memory than with -O1. This option is generally the best choice for deployment of a program, because it provides maximum optimization without increasing the executable size. It is the default optimization level for releases of GNU packages. The second level is enabled as shown below:
LEVEL 2.5: -Os Optimization
The special optimization level (-Os or size) enables all -O2 optimizations that do not increase code size; it puts the emphasis on size over speed. This includes all second-level optimizations, except for the alignment optimizations. The alignment optimizations skip space to align functions, loops, jumps and labels to an address that is a multiple of a power of two, in an architecture-dependent manner. Skipping to these boundaries can increase performance as well as the size of the resulting code and data spaces; therefore, these particular optimizations are disabled.
-Os optimization level simply disables some -O2 optimizations like -falign-labels, -falign-jumps, -falign-labels, and -falign-functions. Each of these has the potential to increase the size of the resulting image, and therefore they are disabled to help build a smaller executable. The size optimization level is enabled as:
In gcc 3.2.2, reorder-blocks is enabled at -Os, but in gcc 3.3.2 reorder-blocks is disabled.
LEVEL 3: -O3 Optimization
The third and highest level enables even more optimizations by putting emphasis on speed over size. This includes optimizations enabled at -O2 and rename-register. The optimization inline-functions also is enabled here, which can increase performance but also can drastically increase the size of the object, depending upon the functions that are inlined. The third level is enabled as:
Although -O3 can produce fast code, the increase in the size of the image can have adverse effects on its speed. For example, if the size of the image exceeds the size of the available instruction cache, severe performance penalties can be observed. Therefore, it may be better simply to compile at -O2 to increase the chances that the image fits in the instruction cache.
Architecture Specification
The optimizations discussed thus far can yield significant improvements in software performance and object size, but specifying the target architecture also can yield meaningful benefits.
The -march option of gcc allows the CPU type to be specified
The default architecture is i386. GCC runs on all other i386/x86 architectures, but it can result in degraded performance on more recent processors. If you're concerned about portability of an image, you should compile it with the default. If you're more interested in performance, pick the architecture that matches your own.
References:
1. Optimization in GCC
2. An Introduction to GCC - for the GNU compilers gcc and g++.
In most situations, faster is better than smaller, because disk space and memory are quite cheap for desktop users. However, for embedded systems small is often at least as important as fast because of a commonplace environment consisting of extreme memory constraints and no disk space, making code optimization a very important task.
Optimization is a complex process. For each high-level command in the source code there are usually many possible combination's of machine instructions that can be used to achieve the appropriate final result. The compiler must consider these possibilities and choose among them.
In general, different code must be generated for different processors, as they use incompatible assembly and machine languages. Each type of processor also has its own characteristics -- some CPU's provide a large number of registers for holding intermediate results of calculations, while others must store and fetch intermediate results from memory. Appropriate code must be generated in each case.
Furthermore, different amounts of time are needed for different instructions, depending on how they are ordered. GCC takes all these factors into account and tries to produce the fastest executable for a given system when compiling with optimization.
Turning optimization flags ON makes the compiler attempt to improve the performance and/or code size at the expense of compilation time and possibly the ability to debug the program.
NOTE: While the GCC optimizer does a good job of code optimization, it can sometimes result in larger or slower images (the opposite of what you may be after). It’s important to test your image to ensure that you’re getting what you expect. When you don’t get what you expect, changing the options you provide to the optimizer can usually remedy the situation.
Let us see various optimization levels provided by GCC
LEVEL 0: -O0 Optimization
At this optimization level GCC does not perform any optimization and compiles the source code in the most straightforward way possible. Each command in the source code is converted directly to the corresponding instructions in the executable file, without rearrangement. This is the best option to use when debugging with a source code debugger (such as the GNU Debugger, GDB). It is the default level of optimization if no optimization level option is specified. It can be specified as
[bash]$gcc -O0 hello.c -o hello
or
[bash]$gcc hello.c -o hello
NOTE: -O0 is actually -(Capital O)(Number 0). Similarly -O1 is -(Capital O)(Number 1).
LEVEL 1: -O1 Optimization (-O)
In the first level of optimization, the optimizer’s goal is to compile as quickly as possible and also to reduce the resulting code size and execution time. Compilation may take more time with -O1 (over -O0), but depending upon the source being compiled, this is usually not noticeable. Level 1 also has two sometimes conflicting goals. These goals are to reduce the size of the compiled code while increasing its performance. The set of optimizations provided in -O1 support these goals, in most cases.
The -O1 optimization is usually a safe level if you still desire to safely debug the resulting image. Check out the table given below for optimizations enabled at different levels.
NOTE: Any optimization can be enabled outside of any level simply by specifying its name with the -f prefix, for example, to enable the defer-pop optimization, we would simply define this as
[bash]$ gcc -fdefer-pop hello.c –o hello
We could also enable level 1 optimization and then disable any particular optimization using the -fno- prefix, like this:
[bash]$ gcc -O1 -fno-defer-pop -o test test.c
This command would enable the first level of optimization and then specifically disable the defer-pop optimization.
LEVEL 2: -O2 Optimization
The second level of optimization provides even more optimizations (while including those in -O1, plus a large number of others). Only optimizations that do not require any speed-space tradeoffs are used, so the executable should not increase in size. The compiler will take longer to compile programs and require more memory than with -O1. This option is generally the best choice for deployment of a program, because it provides maximum optimization without increasing the executable size. It is the default optimization level for releases of GNU packages. The second level is enabled as shown below:
[bash]$gcc -O2 hello.c -o hello
LEVEL 2.5: -Os Optimization
The special optimization level (-Os or size) enables all -O2 optimizations that do not increase code size; it puts the emphasis on size over speed. This includes all second-level optimizations, except for the alignment optimizations. The alignment optimizations skip space to align functions, loops, jumps and labels to an address that is a multiple of a power of two, in an architecture-dependent manner. Skipping to these boundaries can increase performance as well as the size of the resulting code and data spaces; therefore, these particular optimizations are disabled.
-Os optimization level simply disables some -O2 optimizations like -falign-labels, -falign-jumps, -falign-labels, and -falign-functions. Each of these has the potential to increase the size of the resulting image, and therefore they are disabled to help build a smaller executable. The size optimization level is enabled as:
[bash]$gcc -Os hello.c -o hello
In gcc 3.2.2, reorder-blocks is enabled at -Os, but in gcc 3.3.2 reorder-blocks is disabled.
LEVEL 3: -O3 Optimization
The third and highest level enables even more optimizations by putting emphasis on speed over size. This includes optimizations enabled at -O2 and rename-register. The optimization inline-functions also is enabled here, which can increase performance but also can drastically increase the size of the object, depending upon the functions that are inlined. The third level is enabled as:
[bash]$gcc -O3 hello.c -o hello
Although -O3 can produce fast code, the increase in the size of the image can have adverse effects on its speed. For example, if the size of the image exceeds the size of the available instruction cache, severe performance penalties can be observed. Therefore, it may be better simply to compile at -O2 to increase the chances that the image fits in the instruction cache.
Architecture Specification
The optimizations discussed thus far can yield significant improvements in software performance and object size, but specifying the target architecture also can yield meaningful benefits.
The -march option of gcc allows the CPU type to be specified
The default architecture is i386. GCC runs on all other i386/x86 architectures, but it can result in degraded performance on more recent processors. If you're concerned about portability of an image, you should compile it with the default. If you're more interested in performance, pick the architecture that matches your own.
References:
1. Optimization in GCC
2. An Introduction to GCC - for the GNU compilers gcc and g++.
Subscribe to:
Posts
(
Atom
)