Author Topic: how to determine the computer's speed ?  (Read 3807 times)

0 Members and 1 Guest are viewing this topic.

RAIN CODE

  • Guest
how to determine the computer's speed ?
« on: August 28, 2012, 02:49:31 AM »
I tried the lisp below to determine the pc speed but the result (chkspeed count for 1 second)  is not consistent.

(defun PcSpeedCheck ()
 
   ;delay for 1 second and count the addition sum of chkspeed
   ; for pentium 4 pc the sum is 150000
  (setq MarkDelaytime (* 8640000 (getvar"date")))
  (setq chkspeed 0)
  (while
    (< (- (* 8640000 (getvar"date")) MarkDelaytime) 100)
    (setq chkspeed (1+ chkspeed))
  )
 
  (setq globalgamespeed (/ 150000.0 chkspeed))

);defun


but the problem is the chkspeed sum is not consistent.
Is there any better way to check the pc speed ?

thanks.


highflyingbird

  • Bull Frog
  • Posts: 415
  • Later equals never.
Re: how to determine the computer's speed ?
« Reply #1 on: August 28, 2012, 03:02:59 AM »
Code - Auto/Visual Lisp: [Select]
  1. (defun C:CPU(/ t1 t2)
  2.   (setq t1 (getvar 'cputicks))
  3.   (command "delay" 1000)
  4.   (setq t2 (getvar 'cputicks))
  5.   (princ (strcat "\nCPU frequency is:" (rtos (- t2 t1) 2 20)))
  6.   (princ)
  7. )
How about this one?
I am a bilingualist,Chinese and Chinglish.

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: how to determine the computer's speed ?
« Reply #2 on: August 28, 2012, 03:41:35 AM »
Or this perhaps:
Code - Auto/Visual Lisp: [Select]
  1. (defun CPUTicks (/ time tick)
  2.   (setq time (getvar "millisecs")
  3.         tick (getvar "cputicks"))
  4.   (while (< (- (getvar "millisecs") time) 1000))
  5.   (- (getvar "cputicks") tick))
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: how to determine the computer's speed ?
« Reply #3 on: August 28, 2012, 03:56:00 AM »
Actually in your scenario ... I'd not bother trying to figure out the PC/ACad speed. Just decide on how much time between each frame (say 1/10th second for 10fps). Then add a call to this just before updating the screen.
Code - Auto/Visual Lisp: [Select]
  1. (defun wait (ms / time)
  2.   (setq time (getvar "millisecs"))
  3.   (while (< (- (getvar "millisecs") time) ms)))
E.g.
Code - Auto/Visual Lisp: [Select]
  1. (wait 100) ;Wait for 1/10th second
You might have to tweak it a bit depending on how much updating happens, perhaps have a global var for "delay" and add something where you can increase / decrease the delay a bit by modifying that variable. Play around until you feel it runs at the correct speed, then check what the variable is.

You might even leave the increase/decrease so the user can adjust their desired speed for themselves
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: how to determine the computer's speed ?
« Reply #4 on: August 28, 2012, 06:34:41 AM »
Another alternative is as attached.
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

chlh_jd

  • Guest
Re: how to determine the computer's speed ?
« Reply #5 on: August 28, 2012, 07:01:01 AM »
Averaged .
Code: [Select]
(defun c:cpu  (/ cpu l)
  (defun CPU  (/ t1 t2)
    (setq t1 (getvar 'cputicks))
    (command "delay" 1000)
    (setq t2 (getvar 'cputicks))
    (- t2 t1))
  (repeat 12 (gc) (setq l (cons (cpu) l))) 
  (setq l (cdr (reverse (cdr (vl-sort l '<)))))
  (princ (rtos (/ (apply '+ l) 10) 2 20))
  (princ))

RAIN CODE

  • Guest
Re: how to determine the computer's speed ?
« Reply #6 on: August 29, 2012, 08:26:09 AM »
Another thing is, that pacman game (dunno if anyone here have play that game), sometime it slows down, then when the program make another call to the playsound subr it will speeds up again, making the speed of the game not consistent.

I am trying to make it playable.

Thanks. I play around with your suggestions.

I dunno if acad 2002 have cputick ? Hope it have this system variable
« Last Edit: August 29, 2012, 08:37:03 AM by RAIN CODE »

ribarm

  • Gator
  • Posts: 3212
  • Marko Ribar, architect
Re: how to determine the computer's speed ?
« Reply #7 on: August 29, 2012, 09:17:03 AM »
I played pacman and I agree with you... My impressions are that the game is impressive... You put lot of effort to realize it, and my only game play lack is moving - I had to constantly move mouse for a little back and forth to make the game don't pause while keeping main direction for pacman always in front of him... I've cheated and passed whole game - just don't know who will finish it if you don't have unlimited attempts (you only have 3 pacman at the start, but levels are too heavy even for experts - what kid will enjoy it when game is over and at the very beginning after he/she spent their only 3 attempts)... Not to mention big boss at level 16 - you have to have not pacman, but superhero eating jedi master... All in all, animations and music in the end payed off, but if you survived you'll tell stories about it when getting older...
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

RAIN CODE

  • Guest
Re: how to determine the computer's speed ?
« Reply #8 on: September 03, 2012, 12:30:25 AM »
I played pacman and I agree with you... My impressions are that the game is impressive... You put lot of effort to realize it, and my only game play lack is moving - I had to constantly move mouse for a little back and forth to make the game don't pause while keeping main direction for pacman always in front of him... I've cheated and passed whole game - just don't know who will finish it if you don't have unlimited attempts (you only have 3 pacman at the start, but levels are too heavy even for experts - what kid will enjoy it when game is over and at the very beginning after he/she spent their only 3 attempts)... Not to mention big boss at level 16 - you have to have not pacman, but superhero eating jedi master... All in all, animations and music in the end payed off, but if you survived you'll tell stories about it when getting older...

glad you like the game. Only thing is no one is providing bug reports. I am sure the boss level will have lots of bugs since I did not test run it for long time like the 16 levels. I found few bugs from the boss level but did not debug it as I was oversea the last whole week.

Ya I agreed with you, sometimes to win something, you dont need to play by the rules to win it. You can adjust the setting in the game.

Are you running the game in v2002 autocad ? About 10 days ago, I added few new levels until level 21. But after I came back from oversea my interest of the game started to wane off.

I am a very intense person. If I wanted to do something I do that things to the fullest. I will make sure that objective is achieved. But if that interest is no longer there I drop that thing and will do other thing. Now I have something that has been bugging me for sometime and I will put my effort to that until it achieved.


« Last Edit: September 03, 2012, 04:02:20 AM by RAIN CODE »