Category Archives: Computer related

The posts that may be related to computer, programming or IT fields but are not directly (or 100%) programming or computer related.

Another good library for developers — Easy solution

Today, I am happy to share the blog about a .NET library for developers that enables them to create documents in different formats for office and online use. Spire.Doc library is a library for developers trying to solve the interoperability problems with Microsoft Word, PDF, Rich Text Format and HTML format. It was a very amazing library as I went through it and the developer of library has provided a very efficient solution for the API guide along with the product itself.

I have written the review for the API and provided a simple, but a very general example of the usage that a developer can try out, in their applications, for dynamically generating the PDF file and sending it to client. Perhaps, I missed most of the things about the term dynamic in the review post. But, you know… You can always add variables instead of hard-coded strings and objects. Among review, I have provided a couple of scenarios in which the API is very much useful,

  1. Converting documents from one format to another
  2. Reading existing document, or making changes to them
  3. Generating documents on run-time
  4. Sending dynamically created office format files to potential clients
  5. Many more

So, read my review at: [Review] Spire.Doc .NET library for cross-file format document creation and share it with your friends also if they are new to this library, or are still wasting their time thinking what to do and how to solve the interoperability problem with Microsoft office and other file formats. I have provided most of the information bundled into sections. If you find a part missing, or faulty, do hit me with a comment reply. I would look into it.

I will post more stuff for developers, soon!

Count your 9s before blaming your CPU

Recently I was working on a Windows Forms application and I tried to create an async model, to see how long does it take to perform the loops. Although it doesn’t take much time for our CPU to calculate the results for our general loops; thousands, or hundred thousand maximum. I created the model for performing the loop as,

// loops, seconds are defined to be long variables.
private async void runAsync() 
{ 
     long res = await result();  
      resultLabel.Text = String.Format("Result of {0} loop addition is {1}.", loops, res);  
  
      // Done.. Stop the timer..  
      timer.Stop();  
      timerLabel.Text = String.Format("{0} seconds took to calculate result of {1} loops", seconds, loops);  
      seconds = 0;  
}  
  
private async Task<long> result()  
{  
     long res = 0;  
     return await Task.Run(() =>  
     {  
          for (var i = 0; i < loops; i++)  
          {  
               res += i;  
          }  
          return res;  
     });  
}

Well, it probably does what it is asked to do so. The only case of interest is, when the value is given to the loop. Let me show you the results for each of these cases…

Having 0-8 9s.

In case of 9s from 0 to 8, the execution takes only a fraction of one second.

Continuing to 8th result now,

Quite similar behavior being shown in these cases. Which shows that CPU is pretty much fast to calculate this much loops easily and to provide the result; if the result is not correct, please avoid mentioning it.

Adding a 9th 9

With a new 9th 9 being added to the loop; the results now amplify, instead of 1 2 or 3 seconds, it takes up to 8  seconds to execute the loop and provide the results.

That shows the significance of a 9 in the row of loops…

Adding a 10th 9

By using another 9 in the loop, I was finally able to manage to make the CPU work for a longer time… Much much longer time. My CPU doesn’t provide any result for this calculation, and took more than 7 or 8 hundred seconds.

Not bad, eh?

I will not say, CPU was not efficient as it was able to calculate the results for 0-8 9s and then started to topple the time by an increment of each 9 (each 9 made the first 9 in the left side tens, from ones, and hundreds from ones and so on making the loop counter to be billions). The number for the loops was, nine billion nine hundred ninety-nine million nine hundred ninety-nine thousand nine hundred ninety-nine. Which is quite reasonable for the CPU to take this much time.

This reminds me of the “Transistor as an amplifier“, current moves and at a critical level, voltage rises and just keeps rising… I am really glad I found this and took time to write a blog about it. 🙂 Hopefully, next time you will count your nines before saying your CPU is fast!

Multitasking in our brain, can it be compared to that of a computer?

Quite a lot of similar news posts, researches and other paper is available to talk about how worse creation of God was, as a comparison to that of creation of His creation. Some news suggest that brain is no good as compared to a CPU. The funny part about this is that most of these authors are from Universities, playing their much vital (and respectful) role as a professor in psychology or computer science sections. I know, it is a great way to inspire people and gain recognition by giving away a thesis paper or a post with “Science research” tag on it, most engaging I believe.

But we’re actually missing a lot of things… Our computer machines were built right on the base on our body; human anatomy I am talking about. What do you think made the pioneers call CPU, the brain of computer? All of the underlying concept and functionality is similar… It is only the broader look of the machine which attracts you to the goodness of machine. I have not yet quite possibly seen any difference until now. Let us walk through a quite scenarios to talk about the difference… Or more specifically the similarities of a brain to a CPU; computer’s brain.

Multitasking — What is it?

It would be better to first define the term Multitasking itself before going on to comparison about what they are in brain and the CPU. Multitasking is a term coined by computing, in which different (or quite generally and possibly) processes or functions or programs are executed (or performed) simultaneously; concurrently at the same time. You can take the example of this in your modern graphical user-interface based operating systems, where you can run different software at the same time without having to worry about the underlying stuff; such as memory management or clock ticks by the CPU. Operating system does all of this stuff for us, all we have to do is, click on the program to run another program.

At a broader level

Now that the actual concept of multitasking has been shared, it is time to judge a brain’s capability to that of a CPU’s. Let us first of all talk about the broader level of comparison.

A brain, well… Let me talk about my brain while I am writing this post… I am listening to Eminem’s Rap God; awesome song by the way, I am writing this post, I am also chatting with 2 friends of mine and yeah I am also having another article in the queue for code reuse. All of these right at the very same time. I am not getting puzzled, neither am I tripping or loosing the grip from any of these processes; specially that Eminem’s song process. Now let me talk about CPU, my CPU (Intel i5) is performing well a lot of underlying process… But I will talk about those which I am running (because brain also manages the blood, body temperature, sensors and all and I won’t try to count them similarly the OS-based processes are not to be counted in this war), such as I am installing Android SDK, I am playing the music, I am writing this post and I am also having that other article stored and waiting for me to get back onto it and complete it.

From this above paragraph, it is clear to see that at a broader level of comparison, they’re totally alike. There is no difference between any of them, and you can say CPU works as brain.

At a micro level

Now let us talk about what happens at a micro level in both of these objects; CPU and brain. We all know, most of the devices (more specifically CPU) can execute one command at a time; it can be better described by the machine cycle, which is,

  1. Fetch — from RAM to the CPU registers
  2. Decode — Into operator and operands
  3. Execute — perform the operation
  4. Store — It can be a display operation, or to store the data in the RAM back.

Above can describe how the CPU works, and how it executes one command… To be specific, it also takes 4 steps to add 1 with 1; 1 + 1 = 2. We make it better, through pipelining to allow the processor to process 4 different commands in one cycle. Same thing comes with brain, brain performs one task at a time, but all of this happens in a very fast (but not very much fast). According to this very clear and fine research and calculation, our brain, can perform 20 million billion calculations per second. Intel’s i7 processor is capable of performing 298,190 million instructions per seconds; please see Wikipedia page for more.

Personal views…

Now this section might be about my personal views about science searches now a days. But you should read it anyways.

I would like to dis agree to those professors, who believe that human brain is not capable of doing anything… Are you serious? What you think helped humans create these high-speed computers you’re trying to embrace now. No matter how fast you can build the machine, it can never even touch or demonstrate the greatness of the creator. As it has been made clear enough that on the macro level they both act similar, or might even look like CPU is being fast enough to handle multitasking approach, but it is not the case. At the micro level, you will find out that brain is faster. How does then CPU win the race at the macro level?

That is because we… Humans; of this age are just too lame to be fast enough. I am having a very solid excuse for this statement. We, at a very tender age try to ask for a calculator when we have to multiply 23 with 4. I know that is somewhat confusing but, if we focus on it then we can easily get the answer, 92. Just a little focus can enable our mind capabilities which have been sleeping ever since our primary education, because of a computer the calculator. Although performance of our mind can be decreased with aging, but that still is not the case when CPU can over our capabilities. Not only this, stress can also bring down the muscle to a low performance stage, after all it is a muscle; genius one.

Although computer scientists believe that a dual-core is capable of performing two tasks at a time, well… Two brains can then perform two different actions simultaneously. What’s the big deal then? Nothing… No matter how better they perform, how fast they try to make their CPU and machines, they can never reach the strength at which human brain can act. Our brain is the fastest intelligent thing on this planet, we just need to blow away the dust of laziness from our brains. Also, what did Eminem say in his Oscar winning song, Lose yourself? “You can do anything you set your mind to, man!”