473,763 Members | 7,044 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Which is More Efficient?

I have a program that uses up a lot of CPU and want to make it is
efficient as possible with what I have to work with it. So which of the
following would be more efficient, knowing that l is a list and size is
a number?

l=l[:size]
del l[size:]

If it makes a difference, everything in the list is mutable.

May 18 '06
16 1686
Dustan wrote:
Obviously it takes a geek to know you have to time it, as opposed to
any other task you could be talking about.


wasn't the original question "my program uses a lot of CPU, and I want
to make it more efficient" ? what does "a lot of CPU" and "more
efficient" mean to you, and how do you know that your program uses "a
lot of CPU" ?

</F>

May 19 '06 #11

Fredrik Lundh wrote:
Dustan wrote:
Obviously it takes a geek to know you have to time it, as opposed to
any other task you could be talking about.
wasn't the original question "my program uses a lot of CPU, and I want
to make it more efficient" ? what does "a lot of CPU" and "more
efficient" mean to you, and how do you know that your program uses "a
lot of CPU" ?


The task manager says "CPU Usage: 100%" when the program is running,
and only when the program is running.

Efficiency is a measure of 2 things: CPU usage and time. If you measure
just time, you're not necessarily getting the efficiency.

</F>


May 19 '06 #12
Dustan wrote:
Fredrik Lundh wrote:
Dustan wrote:
Obviously it takes a geek to know you have to time it, as opposed to
any other task you could be talking about.


wasn't the original question "my program uses a lot of CPU, and I want
to make it more efficient" ? what does "a lot of CPU" and "more
efficient" mean to you, and how do you know that your program uses "a
lot of CPU" ?


The task manager says "CPU Usage: 100%" when the program is running,
and only when the program is running.

Efficiency is a measure of 2 things: CPU usage and time. If you measure
just time, you're not necessarily getting the efficiency.

</F>


By the way, I've only been programming for a year or so (probably 18
months at the most). I'm sure that can't label me as a 'newbie', but at
least consider that before you criticize me like you did when I asked
about scientific notation.

May 19 '06 #13
"Dustan" <Du**********@g mail.com> wrote in
news:11******** **************@ u72g2000cwu.goo glegroups.com:

The task manager says "CPU Usage: 100%" when the program is
running, and only when the program is running.

Efficiency is a measure of 2 things: CPU usage and time. If you
measure just time, you're not necessarily getting the efficiency.


A lot of people, when they say 'uses a lot of CPU' are leaving off
'time'. I.e., CPU usage is pretty much talked about in terms of
cycles, which is roughly utilization*tim e. Profiling tools often
report both clock time and cpu time. Cpu time is a rough analog for
cycles, clock time is self explanatory.

max

May 19 '06 #14
Dustan wrote:
The task manager says "CPU Usage: 100%" when the program is running,
and only when the program is running.

Efficiency is a measure of 2 things: CPU usage and time. If you measure
just time, you're not necessarily getting the efficiency.


are you for real?

</F>

May 19 '06 #15

Fredrik Lundh wrote:
Dustan wrote:
The task manager says "CPU Usage: 100%" when the program is running,
and only when the program is running.

Efficiency is a measure of 2 things: CPU usage and time. If you measure
just time, you're not necessarily getting the efficiency.
are you for real?


And what exactly is that supposed to mean?

</F>


May 19 '06 #16
Dustan wrote:
Fredrik Lundh wrote:
are you for real?
And what exactly is that supposed to mean?


The obscurity in that communication is probably caused by the instance
of the effbot with which you have been corresponding having been
invoked with mildmannered=Tr ue -- apparently this is not the default
value for that arg and the constraints so imposed can lead to lack of
precision in the output :-)

HTH,
John

May 19 '06 #17

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2919
by: wogston | last post by:
(A) template <typename T> metainline foo<T> lerp(const foo<T>& a, const foo<T>& b, const T& time) { foo<T> v; repeat< 4,exec_mul<T> >::exec(v,a,b,time); return v; }
9
4236
by: Randell D. | last post by:
Folks, I have a large amount of values to store (we're talking tens, if not hundreds of bytes). I need this for a client side application - ignore the security consequences for the moment - however my question is, which is more performance effective, or easier on a clients resources? I mean - if I have several <input type=hidden> tags with my values that I can reference, would this have a greater overhead then, for example, having an...
10
3519
by: Amit | last post by:
Which is more efficient and why? p++ or ++p. Thanks.
12
3233
by: junky_fellow | last post by:
Which is better using a switch statement or the if-then equivalent of switch ?
1
1394
by: JJ | last post by:
I need to do a SELECT query that joins four tables. The largest of the tables could eventually have over 1 million records. I need to do a SELECT that returns a maximum of 1000 records which will display on multiple pages. Which way would be more efficient.... 1. Do the SELECT and LIMIT it to 1000 records, then relying on MySQL's caching, do a data seek to jump to the record that will begin each page. As I understand it, MySQL will do...
2
2632
theGeek
by: theGeek | last post by:
I always wonder which one of join or subquery should I be using to solve a particuar problem so that I get the correct result set in minimum time. It usually happens that I can write a query quickly using subqueries (I think I happen to think that way more easily than join way :)) but I see others making use of joins all the time. May be that they can think of a query more easily using joins. I am saying that because I don't usually see much of...
19
1892
by: santanu mishra | last post by:
Hi , I am stuck with a requirement from my client to change the date format from mm/dd/yy to dd/mm/yy .If any body can help me out with this regard as its very much urgent. Regards, Santanu
50
4504
by: Juha Nieminen | last post by:
I asked a long time ago in this group how to make a smart pointer which works with incomplete types. I got this answer (only relevant parts included): //------------------------------------------------------------------ template<typename Data_t> class SmartPointer { Data_t* data; void(*deleterFunc)(Data_t*);
6
1268
by: Christopher | last post by:
I've seen various ways of doing this, but what I want is to be able to take a base class pointer and know which derived class to cast to. For example I am going to make a base light class, that has a position and intensity. A derived classes class may be a point light which also has a falloff value. The derived class has all the base class methods and data in common, but has the additional falloff value get/set methods.
0
10144
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9997
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9937
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9822
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7366
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5270
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5405
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3522
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2793
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.