On Monday, April 14, 2014 9:06:36 PM UTC+3, Ido Kanner wrote:On Mon, Apr 14, 2014 at 8:45 PM, egon <egon...@gmail.com <javascript:>>wrote:
On Monday, April 14, 2014 8:34:48 PM UTC+3, Ido Kanner wrote:On Mon, Apr 14, 2014 at 7:31 PM, egon wrote:On Monday, April 14, 2014 7:26:55 PM UTC+3, Ido Kanner wrote:
Hello,
I have a small data to compare that is fixed (16 elements).
I can not use a slice or a map as a constant.
This function will be called on each request (by a server), and I wish
to design my server to answer at least 1,000 request per second, and hope
to work with more.
What will be better optimized, and faster to do ?
A. Create a map and find if a key exists (depends on the request).
B. Create a slice with all valid requests, and iterate it, to find if
it exists
Is there even a better way to do it ?
It depends what the key is, how often it is modified and what the
common access patterns are.
The key never changes, it's something like this:
valid := map[string] int {
"v=" : 0x1,
"o=" : 0x2,
// etc...
}
I still have no clue what those mean... nor whether the keys are unique,
or not, whether they have same prefixes or not. Please do not remove
information just because you think it's irrelevant, it makes the discussion
much longer and you may get poor suggestions as a result. Unless I'm able
to write the code that would solve your problem, then you are not giving
enough information. Read
https://code.google.com/p/go-wiki/wiki/HowToAsk, especially the "The story of a bad question" part, there's a reason I
posted it.
Sorry, but *NO*.
I asked a question, that I thought had enough information (access
information -> what is faster X or Y given when there are at least 1,000
access at given second). It wasn't enough, so I gave an example on what I
do (with actual data).
You still didn't give all the data and information what is the data... you
just gave a subset of a data.
If that's not enough for you to help me, that's okay, but I do not know
what else to provide.
Others gave an answer that there are missing information, and explained
what is missing, but you just keep on pasting a document of "howto", that
does not explain a newbie like myself (not in programming, but in Go), and
very frustrating to deal with.
By giving me a FAQ, documents etc to read on how to ask, rather then to
explain to me what you are missing in my information,
I said I'm missing the *context*. I do not know what you are building. Is
it a game, is it a server, is it some data analysis front end, is it some
ACL etc. What are the other processes running on the server. What hardware
is the server running on. etc. What are you using to connect the clients.
Are you using WebSockets or do clients come with floppy disks to the server
and do a request?
Imagine I come to you and ask "What oil do I need to buy for my car, so it
would perform better?"... You ask me "What car is it and under what
conditions you are going to drive it in?"... and I reply "The car is blue
and it has 17 inch wheels."...
will not help me to ask a better question, but rather not to ask at all.
>
It's not a FAQ, it's a page explaining how much information you should give
and how to give it in the shortest way available. To me, it seemed you just
ignored that page... if the suggestion (i.e. reading the page) is unclear,
then say so and do not just skip commenting it; if you explain why it
wasn't clear, I can improve it or explain more...
I'll figure this out by myself, and might rewrite some code on my own, but
I can not provide more details, when I do not know what else is missing for
someone to help me understand, so thank you for your "help", but I guess
the mailing list is not the place for me.
>
Here is the difficulty, I do not know what you are doing, hence I can not
ask you for the specifics without doing a 10 trip back-and-forth about the
system.
All of those examples you provided are plausible, but given the context
may be suitable or not. There are of course more possibilities, like using
map[rune]map[rune]int or map[rune]int or []struct{a, b rune}, or a proper
trie... etc. Essentially profile for your needs.
You are not showing the full problem, which means you won't get a proper
answer.
+ egon
I need to do:
for _, line := range request {
id, ok := valid[line[0:2]]
if ok {
// do something with id
}
}
The other way to do it, is to do write something like so:
func in_string(a_char string, str []string) bool {
for _, ch := range str {
if ch == a_char {
return true
}
}
return false
}
...
valid_chars := []string{ "v", "o", }
if in_string(string(line[0:1]), valid_chars) && line[1:1] == "=" {
...
}
That's what I'm trying to do
Please provide the full context... see
https://code.google.com/p/go-wiki/wiki/HowToAsk ... it'll save time in the discussion.
+ egon
Thanks,
Ido
--
You received this message because you are subscribed to the Google
Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to golang-nuts...@googlegroups.com.
For more options, visit
https://groups.google.com/d/optout.--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to golang-nuts...@googlegroups.com <javascript:>.
For more options, visit
https://groups.google.com/d/optout.--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit
https://groups.google.com/d/optout.