Bushranger Posted December 11, 2019 Posted December 11, 2019 (edited) Using Visual Basic 2010 Express, Windows 10, 8GB ram. I wrote a text encrypting program about five years ago. It works, however the part of the program that encrypts the text runs very slow (30 seconds or more for a one sentence message). Which makes no sense to me in that the part of the program that un-encrypts the data runs very fast (3 seconds or less). Some posters have suggested using Multithreading or Backgroundworker, however that does not seem a remedy in that my program does not require the operator to do anything but wait for the data to process. I have read that there are techniques to make the coding more efficient. For instance, I read where instead of using the word "string" to declare a data type, I use a "$" to declare staring data which uses less memory. That is what I am looking for...more efficient programing in that my crude method of programing may be causing the slowness of that part of the program. I am also concerned about the scope of my declarations my not be correct and contributing to the problem. For instance I have "Dim", "Friend" and "Public" in my declarations...can that cause a problem with speed? Suggestions welcome. Edited December 15, 2019 by elsiegee40 RAM size corrected by Mods
Bushranger Posted December 11, 2019 Author Posted December 11, 2019 What encryption algo are you using? My own invention...three different levels all involving Select Case statements. I would describe it as changing English characters into a different alphabet and then changing it into another different alphabet and then changing it yet again. I won't go into it any deeper because it is a "secret" method after all.
mavhc Posted December 11, 2019 Posted December 11, 2019 hopefully you're not using this for anything important, just to learn to program, creating your own encryption is always a bad idea, unless you're an expert. To fix problems with speed you want to look into something called Profiling https://docs.microsoft.com/en-us/visualstudio/profiling/ Seems like there's lots of youtube videos too. That should help you find the 1% of your code that's using 99% of the time 1
Bushranger Posted December 12, 2019 Author Posted December 12, 2019 hopefully you're not using this for anything important, just to learn to program, creating your own encryption is always a bad idea, unless you're an expert. To fix problems with speed you want to look into something called Profiling https://docs.microsoft.com/en-us/visualstudio/profiling/ Seems like there's lots of youtube videos too. That should help you find the 1% of your code that's using 99% of the time Thank you...that program looks to be very useful in my endeavors. As I have posted (in another thread), my program (which I started many years ago, originally in VB2, then re-programed in VB 2010 Express about five years ago), was written as a self-challenge due to my (compulsive) interest in history and the WWII German Enigma Code and the British Bletchley Park de-coding effort. So, the program has no practical application, nor can I envision one at this time. Nevertheless, I would eat my underwear if anyone could take a message that has been encrypted by my program and figure it out without using my program to solve it. It cannot be solved using statistical analysis, etc. It is for fun and to help keep my mind sharp inasmuch as I am an elderly person. However, being a High-Functioning Asperger's person, the fact that it runs way too slow (inefficient), drives me to distraction (as an "ASPY" I am compelled to "fix" broken things.).
mavhc Posted December 12, 2019 Posted December 12, 2019 Sounds cool, there's not much reason a program like that should be slow these days, only slow parts of a computer really are input and output. Only suggestion is maybe you're making 1000s of copies of long strings or something similar
Steve21 Posted December 12, 2019 Posted December 12, 2019 (edited) I won't go into it any deeper because it is a "secret" method after So, the program has no practical application, nor can I envision one at this time.... the fact that it runs way too slow (inefficient), drives me to distraction (as an "ASPY" I am compelled to "fix" broken things.). I mean in all fairness you're going to have to pick one of the two. Either it's important not to tell anyone the code because it needs to be secret, then there's not much we can help suggest, or it's important to fix it and then really we need to see what is actually being run to see why it might be slow, else it's just going to be listing hundreds of basic things to look at which seems a waste of everyones time really... (In the sense we could list stuff you aren't even using which gets us all nowhere fast) Steve Edited December 12, 2019 by Steve21
Bushranger Posted December 12, 2019 Author Posted December 12, 2019 I mean in all fairness you're going to have to pick one of the two. Either it's important not to tell anyone the code because it needs to be secret, then there's not much we can help suggest, or it's important to fix it and then really we need to see what is actually being run to see why it might be slow, else it's just going to be listing hundreds of basic things to look at which seems a waste of everyones time really... (In the sense we could list stuff you aren't even using which gets us all nowhere fast) Steve I think that the program that was suggested, "Profiling", will be all I need for awhile.
Bushranger Posted December 13, 2019 Author Posted December 13, 2019 (edited) To fix problems with speed you want to look into something called Profiling https://docs.microsoft.com/en-us/visualstudio/profiling/ Seems like there's lots of youtube videos too. That should help you find the 1% of your code that's using 99% of the time It would appear that Profiling is not available with Visual Basic 2010 Express (what I am using). However it is part of Visual Studio 2019. My question now becomes: If I upgrade to Visual Studio 2019 to get the Profiling tools, will my existing program remain intact? Also, after studying my program, It occurred to me that the bottle neck may be due to the fact that there are string data being appended to a disk file throughout the processing of the data. That is, there are many, many writes to the disk to append the file. I suspect that I can eliminate the bottle neck (if that is truly the cause), by appending all the data into a text box and then writing it to the file after the process is completely finished. In other words, frequent appends to the text box instead of to the file on the hard drive. Does that sound like I could be on the right track? Edited December 13, 2019 by Bushranger
mavhc Posted December 13, 2019 Posted December 13, 2019 It would appear that Profiling is not available with Visual Basic 2010 Express (what I am using). However it is part of Visual Studio 2019. My question now becomes: If I upgrade to Visual Studio 2019 to get the Profiling tools, will my existing program remain intact? Also, after studying my program, It occurred to me that the bottle neck may be due to the fact that there are string data being appended to a disk file throughout the processing of the data. That is, there are many, many writes to the disk to append the file. I suspect that I can eliminate the bottle neck (if that is truly the cause), by appending all the data into a text box and then writing it to the file after the process is completely finished. In other words, frequent appends to the text box instead of to the file on the hard drive. Does that sound like I could be on the right track? Shouldn't be a problem upgrading, but backup the files first. Ah, if you're writing to the disk, that'll be bad. Just store the text in a string variable, unless there's some limit on how long those can be. 1
Bushranger Posted December 14, 2019 Author Posted December 14, 2019 (edited) Shouldn't be a problem upgrading, but backup the files first. Ah, if you're writing to the disk, that'll be bad. Just store the text in a string variable, unless there's some limit on how long those can be. I changed my program so that it wrote the data as processed into a textbox and not writing to the disk. I added a button control that then wrote the data to the disk file. It would to go faster at first, then would bog down (speed of processing as indicated by the progress bar), but eventially always finishes. But in all it was faster...but obvious to me there is still a problem. At this point it seems that I don't have much choice but to upgrade to get the Profiling feature. Edited December 14, 2019 by Bushranger
Bushranger Posted December 14, 2019 Author Posted December 14, 2019 hopefully you're not using this for anything important, just to learn to program, creating your own encryption is always a bad idea, unless you're an expert. Can you give your rationale why it is a bad idea to create my own encryption system?
markwilfan Posted December 14, 2019 Posted December 14, 2019 Would you let a plumber service your car?
3s-gtech Posted December 14, 2019 Posted December 14, 2019 Interjecting here - yes, I would if they were sufficiently capable of doing so. I’m capable of doing things outside of my profession, where I take an interest in them. I’m sure the OP is the same - I’d guess this would never be for a commercial application anyway.
Bushranger Posted December 14, 2019 Author Posted December 14, 2019 Would you let a plumber service your car? Adults only please.
markwilfan Posted December 14, 2019 Posted December 14, 2019 Yeh you've said that before. What I'm saying is encryption is an art form in itself. If you are not an encryption expert why would you reinvent the wheel.
Bushranger Posted December 14, 2019 Author Posted December 14, 2019 (edited) Interjecting here - yes, I would if they were sufficiently capable of doing so. I’m capable of doing things outside of my profession, where I take an interest in them. I’m sure the OP is the same - I’d guess this would never be for a commercial application anyway. You are correct...it will not likely ever be a commercial application. However, the method does work...and works very well in a cryptologic sense, employing several anti-code breaking techniques and it does encrypt and decrypt plain text (upper and lower case, numeric, and all the standard keyboard characters) successfully. Edited December 14, 2019 by Bushranger
Bushranger Posted December 14, 2019 Author Posted December 14, 2019 (edited) Yeh you've said that before. What I'm saying is encryption is an art form in itself. If you are not an encryption expert why would you reinvent the wheel. For the fun of it...the challenge of it...for the interest in the history of it (please read my first post). Edited December 15, 2019 by elsiegee40 Edited for Language by mods
Steve21 Posted December 14, 2019 Posted December 14, 2019 (edited) For the fun of it...the challenge of it...for the interest in the history of it (please read my first post). As I said before, if it’s for the fun and challenge you need to actually show us what isn’t working to be able to help you, but seems you don’t want to for some unknown reason and then just get annoyed when people suggest alternatives Steve Edited December 15, 2019 by elsiegee40
elsiegee40 Posted December 15, 2019 Posted December 15, 2019 (edited) A little gentle moderator intervention here. I have done a little editing in this thread. To EduGeeks posting in this thread, perhaps the way to go with this one is to say what you mean and avoid your usual wry humour as it appears that some things may not be translating across international boundaries. @Bushranger, you may not appreciate their sense of humour, but the other people posting here are genuinely trying to help. Just saying “Adults only please” is more likely to irritate than encourage them to continue to attempt to help you. If something is said that you don’t like then please report the post and then ignore it, rather than respond in irritation, and the moderators will deal with it. Edited December 15, 2019 by elsiegee40 2
mavhc Posted December 15, 2019 Posted December 15, 2019 (edited) Can you give your rationale why it is a bad idea to create my own encryption system? https://www.schneier.com/crypto-gram/archives/1998/1015.html#cipherdesign Read everything Schneier writes. Edited December 16, 2019 by elsiegee40
Bushranger Posted December 15, 2019 Author Posted December 15, 2019 https://www.schneier.com/crypto-gram/archives/1998/1015.html#cipherdesign Read everything Schneier writes. It may be the different cultures, but how does the above article help me in any way with a "hobbie" program that is running slow. Was there any suggestion in that article as to how to get the program to run faster?
Bushranger Posted December 15, 2019 Author Posted December 15, 2019 (edited) Addendum: I have downloaded Visual Studio 2019 Community and found that I was able to import my project from Visual Basic 2010 into it. At this point I am working on getting to understand and use the Profiling feature in its Debug. Again, thank you to mavhc for the helpful suggestion that I look into upgrading to Visual Studio 2019 Community...I did not know that the upgrade and Profiling even existed. Edited December 16, 2019 by Bushranger
elsiegee40 Posted December 16, 2019 Posted December 16, 2019 I think we have established now that you wish to experiment with coding your own encryption routine. Without seeing what you have coded or your database structure it is hard to provide concrete helpful answers. I have many years experience of both coding and database optimisation. Admittedly my experience is on mainframe but the theory doesn’t change. In modern times, without problems of disk head movements, database and coding optimisation is an art that has been lost. Code turns into spaghetti and nobody bothers to think about how to structure a database to make things run faster. It does matter and it does make a difference. Do look at the way your database is put together and the indexing. If it isn’t properly optimised, you end up making unnecessary calls that slow code down. Do look at your code too and strip it down so that you aren’t executing 500 instructions where 50 would do it.
mavhc Posted December 16, 2019 Posted December 16, 2019 It may be the different cultures, but how does the above article help me in any way with a "hobbie" program that is running slow. Was there any suggestion in that article as to how to get the program to run faster? That link was about why you shouldn't write your own encryption (except as a hobby)
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now