Jump to content




Lag-o-Meter


  • You cannot reply to this topic
19 replies to this topic

#1 Glotz659

  • Members
  • 23 posts
  • Location127.0.0.1

Posted 21 January 2013 - 04:47 AM

Hey,

I think it would be useful to have a function or peripheral to get the current frame rate of the game, so we can switch large, lag producing machines (scrap-production for mass fabricator, giant turtle swarm, water mill power plant etc) off if the game lags too much.

Syntax could be like
.getFrameRate() -- would return the frame rate as a number

sry if its bad english, its not my native language.

#2 redeye83

  • Members
  • 202 posts
  • LocationUnited Kingdom

Posted 21 January 2013 - 04:54 AM

cant you just press "F3" and see the current FPS?

#3 Cloudy

    Ex-Developer

  • Members
  • 2,543 posts

Posted 21 January 2013 - 04:57 AM

Definitely not. Makes no sense from the context of the game world.

#4 Glotz659

  • Members
  • 23 posts
  • Location127.0.0.1

Posted 21 January 2013 - 05:01 AM

View Postredeye83, on 21 January 2013 - 04:54 AM, said:

cant you just press "F3" and see the current FPS?

I can, but a computer can't, so i would have switch it off manually, and traveling a long distance or even between dimensions (i have a solar power plant in a bright mystcraft dimension) with lag is a pain.

edit: maybe you didn't understand waht i meant, so here's an example script:
-- startup file on a computer far from your base
rs.setOutput("back", true) -- switches machine (e.g. timer) on
while true do
if os.getFrameRate() < 30 then
  rs.setOutput("back", false) -- switches machine off again
end
sleep(60)
end


#5 redeye83

  • Members
  • 202 posts
  • LocationUnited Kingdom

Posted 21 January 2013 - 05:26 AM

ah I didnt realise you wanted to due it auto (I feel stupid now lol)

#6 Dlcruz129

    What's a Lua?

  • Members
  • 1,423 posts

Posted 21 January 2013 - 05:30 AM

View PostGlotz659, on 21 January 2013 - 05:01 AM, said:

View Postredeye83, on 21 January 2013 - 04:54 AM, said:

cant you just press "F3" and see the current FPS?

I can, but a computer can't, so i would have switch it off manually, and traveling a long distance or even between dimensions (i have a solar power plant in a bright mystcraft dimension) with lag is a pain.

edit: maybe you didn't understand waht i meant, so here's an example script:
-- startup file on a computer far from your base
rs.setOutput("back", true) -- switches machine (e.g. timer) on
while true do
if os.getFrameRate() < 30 then
  rs.setOutput("back", false) -- switches machine off again
end
sleep(60)
end

Again,

View PostCloudy, on 21 January 2013 - 04:57 AM, said:

Definitely not. Makes no sense from the context of the game world.


#7 Leo Verto

  • Members
  • 620 posts
  • LocationOver there

Posted 21 January 2013 - 05:40 AM

The frame rate is client-side, the code is executed server-side, this wouldn't work very well on servers.

#8 Exerro

  • Members
  • 801 posts

Posted 21 January 2013 - 08:01 AM

you can do it kind of btw using os.clock

#9 Cloudy

    Ex-Developer

  • Members
  • 2,543 posts

Posted 21 January 2013 - 08:05 AM

Nah, not really - clock is only advanced on ticks too, and sleep works on ticks.

#10 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 21 January 2013 - 08:14 AM

View PostCloudy, on 21 January 2013 - 08:05 AM, said:

Nah, not really - clock is only advanced on ticks too, and sleep works on ticks.
Is a timer ticks? If not you could get a TPS working with clock and a timer.

#11 Exerro

  • Members
  • 801 posts

Posted 21 January 2013 - 08:18 AM

you can measure how long it takes for the computer to go through your code with os.clock and sleep according to that surely?

#12 Cloudy

    Ex-Developer

  • Members
  • 2,543 posts

Posted 21 January 2013 - 08:55 AM

Everything is based on ticks.

#13 NeverCast

  • Members
  • 400 posts
  • LocationChristchurch, New Zealand

Posted 21 January 2013 - 10:08 AM

I had my suspicion that everything was based on ticks, which does shatter an idea I had.
Cloudy, how about the alarms, I take it they are 100% ticks also, since they use MC time which is incremented by a 20th of a second, each tick.

Well at least the game is fully synchronized, slow or fast, everything always gets the same amount of ticks.

I think the only luck beyond this would be http with a real world clock. Checking the time difference, if there is a slew of more than 40/50% you could shut down things.

#14 Cloudy

    Ex-Developer

  • Members
  • 2,543 posts

Posted 21 January 2013 - 01:06 PM

Yes, alarms are based off ticks. Everything is based off ticks.



#15 ChunLing

  • Members
  • 2,027 posts

Posted 21 January 2013 - 01:07 PM

Or, you can just take care to program things so that they yield until they are actually needed to do something, or even shut themselves off if they aren't in use.

#16 Orwell

    Self-Destructive

  • Members
  • 1,091 posts

Posted 21 January 2013 - 01:20 PM

And eventually you could use the HTTP api (if available) to compare ticks with elapsed time through a time server. This would only work properly over larger intervals I suppose.

#17 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 21 January 2013 - 01:45 PM

View PostCloudy, on 21 January 2013 - 01:06 PM, said:

Yes, alarms are based off ticks. Everything is based off ticks.

- video snip -
LOL!!! Nice...

#18 ChunLing

  • Members
  • 2,027 posts

Posted 21 January 2013 - 09:52 PM

Lister, as usual exercising less than the minimum safe hygienic discretion. "Hmm...everyone's dead, so I'll taste some of this white powder lying about."

#19 Zoinky

  • Members
  • 144 posts
  • LocationWellington, New Zealand

Posted 22 January 2013 - 07:56 PM

Orwell's idea would work the best. It wouldn't be possible to compare two in-game times, since they're both advancing at the same rate (Eg. The computer could think 1 second has elapsed when it actually has been 2). I'm not great at explaining.

Off-topic-ish: How does the server calculate the TPS? Does it reference other machine times?

#20 immibis

    Lua God

  • Members
  • 1,033 posts
  • LocationWellington, New Zealand

Posted 22 January 2013 - 10:14 PM

View PostZoinky, on 22 January 2013 - 07:56 PM, said:

Orwell's idea would work the best. It wouldn't be possible to compare two in-game times, since they're both advancing at the same rate (Eg. The computer could think 1 second has elapsed when it actually has been 2). I'm not great at explaining.

Off-topic-ish: How does the server calculate the TPS? Does it reference other machine times?
Java code can easily access real and in-game time to compare them.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users