π« Don't do this:
List<int> numbers = new List<int>();
for (int i = 0; i < 1000; i++)
{
numbers.Add(i);
}
β Do this instead:
List<int> numbers = new List<int>(1000);
for (int i = 0; i < 1000; i++)
{
numbers.Add(i);
}
π Explanation:
Pre-allocating the list size can improve performance by reducing the number of memory reallocations as the list grows. #CSharp #CodeQuality #BestPractices
OpenAI API is great for simple, one-off queries, offering quick responses. But for a more interactive, context-aware AI experience, the Assistant API is ideal. It maintains context over multiple interactions, perfect for back-and-forth conversations, handling complex queries and providing personalized responses. #AI #OpenAI #GPT #AssistantAPI
I started using Notion a while ago and now I prefer to create new pages in Notion instead of using MS Word or Google Docs. Notion is quite suitable for simple documentation tasks and, to be honest, it has replaced my office stack. For more complex documents, like scientific articles for instance, I use Overleaf. #notion
π Just implemented the FCFS scheduling algorithm in Python! ππ‘
FCFS is a simple yet effective scheduling strategy where tasks are executed in the order they arrive. It's perfect for scenarios where tasks are non-divisible and can be executed on any machine. π₯οΈ
Here's a quick overview of how it works:
Task Arrival: Tasks arrive at specific times.
Execution: Tasks are assigned to machines based on their arrival time, with the first task going to the first available machine.
Completion Time: We calculate the completion time for each task, considering the time it takes to execute and any potential waiting time.
Average Flow Time (Fsr): The key metric here is the average flow time, calculated by summing the flow times of all tasks and dividing by the number of tasks. This gives us an insight into the efficiency of our scheduling.
Check out the code snippet below to see how it's done:
https://t.co/2TXdPEOhvC
This implementation is a basic example. In real-world scenarios, you might need to consider more factors and optimize further. But for simple, non-divisible tasks, FCFS is a solid choice! ππ‘
#Python #Algorithm #Scheduling #FCFS #Coding #Programming