in reply to Re^2: How to Iterate to Identify Concurrent Users
in thread How to Iterate to Identify Concurrent Users

"The total number of concurrent users" doesn't define much. If you mean "the number of users ever", then say that. If you mean "the number of users that had at least one other user logged in at the same time", that might make sense. For example, if one user logs in at 5, and leaves at 8, and another user logs in at 6, and leaves at 9, and a third user logs in from 10 to 11, how many is that? Two, or Three, or none? :)

Or maybe you mean average users over time, which from 5 to 11 pm on that example is (calculating... 3 + 3 + 1 over 6) 2.333 or so.

  • Comment on Re^3: How to Iterate to Identify Concurrent Users

Replies are listed 'Best First'.
Re^4: How to Iterate to Identify Concurrent Users
by Anonymous Monk on Oct 26, 2007 at 01:00 UTC
    Randal,

    >if one user logs in at 5, and leaves at 8, and another user >logs in at 6, and leaves at 9, and a third user logs in from >10 to 11, how many is that? Two, or Three, or none? :)

    That would be 2, given your example. I mean the total number of simultaneous users on the system at a particular point in time. Any overlapping session of two users counts as two concurrent users. I hope this makes sense to the Greatest Monk of all ;-}

      So you mean (to quote from my earlier post) "A list indicating the number of concurrent users whenever that number changes". Something like this:

      use strict; use warnings; my @events = qw(1+ 3+ 4- 5+ 5+ 6- 6- 6- 9+ 10-); my $lastEpoch = 0; my $conections = 0; for (@events) { my ($epoch, $event) = /(\d+)(.)/; print "$lastEpoch: $conections\n" if $lastEpoch and $lastEpoch != +$epoch; $event eq '+' ? ++$conections : --$conections; $lastEpoch = $epoch; } print "$lastEpoch: $conections\n";

      Prints:

      1: 1 3: 2 4: 1 5: 3 6: 0 9: 1 10: 0

      Perl is environmentally friendly - it saves trees