-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do not use URLs that were in previously used and saved in DB
- Loading branch information
Showing
6 changed files
with
105 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,43 @@ | ||
const VirtualUser = require('./virtual-user-ws') | ||
const fs = require('fs') | ||
|
||
vu01 = new VirtualUser("01234", "public_goods_game", "http://localhost:8060") | ||
vu02 = new VirtualUser("05678", "public_goods_game", "http://localhost:8060") | ||
vu03 = new VirtualUser("91011", "public_goods_game", "http://localhost:8060") | ||
function randomBetween(min, max) { | ||
return Math.floor( | ||
Math.random() * (max - min) + min | ||
) | ||
} | ||
|
||
vu01.connect().then(() => { | ||
vu01.attemptNormalQueueFlow() | ||
}) | ||
vu02.connect().then(() => { | ||
vu02.attemptNormalQueueFlow() | ||
}) | ||
vu03.connect().then(() => { | ||
vu03.attemptNormalQueueFlow() | ||
const maxUsers = 1000 | ||
const experimentId = "public_goods_game" | ||
const url = "http://localhost:8060" | ||
const virtUsers = {} | ||
|
||
for (let i = 0; i < maxUsers; i++) { | ||
const id = 1000 + i | ||
//const id = randomBetween(1, 9999999) | ||
vu = new VirtualUser(id, experimentId, url) | ||
virtUsers[id] = vu | ||
} | ||
|
||
Object.values(virtUsers).forEach(vu => { | ||
vu.connect().then(() => { | ||
vu.attemptNormalQueueFlow() | ||
}) | ||
}) | ||
|
||
setTimeout(() => { | ||
const ids = Object.values(virtUsers).filter(vu => { | ||
if (vu.state == "redirected"){ | ||
return true | ||
} | ||
}).map(vu => { | ||
return vu.userId | ||
}) | ||
const idsString = JSON.stringify(ids, null, 2) | ||
fs.writeFile('redirected_users.json', idsString, (err) => { | ||
if (err) { | ||
console.log('Error ', err) | ||
} | ||
}) | ||
}, 5000) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters