Questions tagged [processing-efficiency]

622 questions
-2
votes
1 answer

(JavaScript) Creating a more efficient algorithm than the one I had

I have this situation : let scans = [ { source: "10.0.0.2", destination: "20.0.0.2" } { source: "10.0.0.4", destination: "20.0.0.6" } ] const handleScan = (source, destination, port) => { let newScan = { …
apollo24
  • 303
  • 4
  • 16
-2
votes
1 answer

How could I make my Python 3 code more compact?

This is my code and I find it to be a bit bulky and repetitive. """ Key UCIO = User Chosen Input Operation x = Global variable, The first number the user would operate with y = Global variable, The second number the user would…
-2
votes
3 answers

Project Euler #23 efficiency

I am trying to write a program in python to answer the following problem: A perfect number is a number for which the sum of its proper divisors is exactly equal to the number. For example, the sum of the proper divisors of 28 would be 1 + 2 + 4 +…
user8502474
-2
votes
1 answer

DB: how to handle large amount of CRUD queries properly due to a change that was made?

I am using MongoDB over a Node.js backend API. Works awesome. When user inserts a new post, I want to update it's followers, it's followers are not officially listed as followers in a collection of followers, they are just potential users to be…
-2
votes
1 answer

Ambiguity in pow(x,y,z) and x**y%z speed in python 3. Which one is efficient?

results are not as expected. pow(x,y,z) must be efficient, but the results altered. why? import…
-2
votes
1 answer

How to identify a set of objects from a large number of possible set combinations; efficient structures or models

I've been battling a problem I have and I can seem to figure out how to solve it. I will not give the exact problem but I will translate it into a simpler form. This is the simplest form I came up with: PROBLEM: You have an object type with some…
-2
votes
2 answers

Extracting list of common words within Ruby array

I hope that I'll be able to articulate this clearly, please forgive me if not. Right now I've got an array of strings with essentially file-paths, like described here: 2.1.7 :002 > a => ["stuff/things/oranges", "stuff/things/bananas",…
Chiggins
  • 8,197
  • 22
  • 56
  • 81
-2
votes
1 answer

Accessing and filtering an array much more efficiently in php

I wrote a code to filter an json array and print some elements, but it caused a banishment for me for too much cpu usage (free hosting plan) can you help me make it more efficient? perhaps by using functions like array_filter here is my code: $obj =…
Zanyar
  • 9
  • 5
-2
votes
1 answer

Can someone help me make this code more efficient?

I'm creating a skill tree calculator for a game. I wrote a method that checks whether or not it can subtract a point from the skill and then proceeds to do so. Everything is working as it should, however it's very slow when this method is executed…
-2
votes
1 answer

Most efficient way to compare two datasets and find results

If I have two data sets which come from SQL tables which appear like this. Where table A contains 3 possible values for a given item and Table B containts a full path to a file name, I have two data sets which come from SQL tables which appear…
wondergoat77
  • 1,765
  • 9
  • 32
  • 60
-2
votes
1 answer

Efficiency - looping greater than the sum of it's parts?

This is a question of concept, and I am just moving from MS Access to SQL Server for stability and scalability. I need to maintain a database that pulls from another server daily. Due to the possibility (and probability) of record changes on the…
BumpML
  • 105
  • 1
  • 2
  • 6
-2
votes
1 answer

most efficient way to set an image

There must be some more efficient way to set an image isn't there? Or is this as good as it gets? public Image setImage(String img){ ImageIcon imageIcon = new ImageIcon(setURL("Images/" + img)); Image image; image =…
AMDG
  • 1,118
  • 1
  • 13
  • 29
-3
votes
1 answer

linked list Sorting in alphabetically and frequency order

I have a linked list project. So I wrote the insert method, getCount(E key){Count of frequency of word inserted(haw many of the words are repeated) },getWords(int n) { gets the first n words in format of (word, count)},iterator(). and my out put…
Ali
  • 1
  • 3
-3
votes
1 answer

Which is faster - Conditional String Formatting or Conventional if/else?

Method 1 - Conventional if/else: from collections import Counter sentence = Counter(input("What would you like to say? ").lower()) sentence_length = 0 for k, v in sentence.items(): if v > 1: print("There are {} {}'s in this…
-3
votes
2 answers

Small Java app performance

I have a program for my CS class and i need to cut the runtime down by a lot when i get big inputs. Here is the code import java.util.Scanner; import java.util.ArrayList; public class Main{ public static void main (String[] args){ Scanner…
1 2 3
41
42