~certify-web-dev/twisted/certify-trunk

« back to all changes in this revision

Viewing changes to twisted/metrics/test-client.py

  • Committer: Bazaar Package Importer
  • Author(s): Moshe Zadka
  • Date: 2002-03-08 07:14:16 UTC
  • Revision ID: james.westby@ubuntu.com-20020308071416-oxvuw76tpcpi5v1q
Tags: upstream-0.15.5
ImportĀ upstreamĀ versionĀ 0.15.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Twisted, the Framework of Your Internet
 
2
# Copyright (C) 2001 Matthew W. Lefkowitz
 
3
 
4
# This library is free software; you can redistribute it and/or
 
5
# modify it under the terms of version 2.1 of the GNU Lesser General Public
 
6
# License as published by the Free Software Foundation.
 
7
 
8
# This library is distributed in the hope that it will be useful,
 
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
11
# Lesser General Public License for more details.
 
12
 
13
# You should have received a copy of the GNU Lesser General Public
 
14
# License along with this library; if not, write to the Free Software
 
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
16
 
 
17
import random
 
18
import time
 
19
 
 
20
from twisted.internet import tcp, main
 
21
 
 
22
import client
 
23
 
 
24
 
 
25
def getTestValue():
 
26
    value = int(time.time() * random.random())
 
27
    return value
 
28
 
 
29
c = client.MetricsClientComponent(7, "localhost", 8787)
 
30
c.doLogin("localMachine", "pass")
 
31
 
 
32
c.createStateVariable("state", getTestValue, 10)
 
33
c.createCounterVariable("counter1", 3)
 
34
c.createCounterVariable("counter2", 4)
 
35
c.createCounterVariable("counter3", 5)
 
36
 
 
37
i = 0
 
38
while 1:
 
39
    main.iterate()
 
40
    i = i + 1
 
41
    if i % 5 == 0:
 
42
        ##
 
43
        r = random.random() * 40
 
44
        if r < 10:
 
45
            c.incrementCounterVariable("counter1")
 
46
            c.incrementCounterVariable("counter1")
 
47
            c.incrementCounterVariable("counter1")
 
48
            c.incrementCounterVariable("counter1")
 
49
            c.incrementCounterVariable("counter1")
 
50
            c.incrementCounterVariable("counter1")
 
51
            c.incrementCounterVariable("counter1")
 
52
            c.incrementCounterVariable("counter1")
 
53
            c.incrementCounterVariable("counter1")
 
54
            c.incrementCounterVariable("counter1")
 
55
            c.incrementCounterVariable("counter1")
 
56
            c.incrementCounterVariable("counter1")
 
57
            c.incrementCounterVariable("counter1")
 
58
            c.incrementCounterVariable("counter1")
 
59
            c.incrementCounterVariable("counter1")            
 
60
 
 
61
        r = random.random() * 40
 
62
        if r < 20:
 
63
            c.incrementCounterVariable("counter2")
 
64
 
 
65
        r = random.random() * 40
 
66
        if r < 30:
 
67
            c.incrementCounterVariable("counter3")
 
68
 
 
69
    c.update()
 
70
    time.sleep(0.1)